Contest Duration: ~ (local time) (150 minutes) Back to Home

Submission #1540291

Source Code Expand

Copy
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
using namespace std;
typedef long long LL;
const int N = 1e6+7 , INF = 0x3f3f3f3f , mz = 1e9+7;
const double PI = acos(0.0) * 2;
template<typename T1>
T1 gcd(T1 a , T1 b){ return b ? gcd(b,a%b) : a;}

int q[6],p[6],r[6],n;
bool cmp(const int a,const int b){
return 1.0*q[a]/p[a] < 1.0*q[b]/p[b];
}

int main(){
#ifdef LOCAL
freopen("F:\\c++\\in.txt", "r", stdin);
//  freopen("F:\\c++\\out1.txt","w",stdout);
#endif

for(int i = 1 ; i <= 4 ; i++){
scanf("%d",q+i);
p[i] = i == 1 ? 1 : p[i-1] * 2;
r[i] = i;
}
sort(r+1,r+5,cmp);
scanf("%d",&n);
n<<=2;
LL ans = 0;
for(int i = 1 ; n && i < 5 ; i++ ){
//printf("r[i] = %d , n = %d , p[r] = %d\n",r[i],n,p[r[i]]);
if( n >= p[r[i]] ){
LL cnt = n / p[r[i]];
ans += cnt * q[r[i]];
n -= cnt * p[r[i]];
}
}
printf("%lld\n",ans);
return 0;
}


#### Submission Info

Submission Time 2017-08-26 21:19:55+0900 A - Ice Tea Store low_and_up C++14 (GCC 5.4.1) 0 1139 Byte WA 1 ms 256 KB

#### Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:30:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",q+i);
^
./Main.cpp:35:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^


#### Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB
sample_04.txt 1 ms 256 KB