제출 #334497

#제출 시각아이디문제언어결과실행 시간메모리
334497giorgikob비스킷 담기 (IOI20_biscuits)C++14
컴파일 에러
0 ms0 KiB
//#include "biscuits.h" #include <cassert> #include <cstdio> #include<bits/stdc++.h> #define ll long long #define ff first #define ss second #define pb push_back using namespace std; const int K = 61; long long count_tastiness(long long x, std::vector<long long> a) { vector<ll>dp(K,0); dp[0] = 1; ll sum = a[0]; while(a.size() < K) a.pb(0); for(ll i = 1; i < K; i++){ if(((1LL<<i)-1) > 1e18/x) { dp[i] = dp[i-1]; continue; } ll b = ((1LL<<i)-1)*x; //cout << b << endl; ll y = 0; bool ok = false; for(ll j = i-1; j >= 0; j--){ y += min(a[j],(b-y)/(1LL<<j))*(1LL<<j); if(y > 1e18){ ok = true; dp[i] = dp[i-1]; break; } } if(ok) continue; //cout << y << endl; int k = i-1; while(y >= 0 && k >= 0){ dp[i] += dp[k]; y -= x*(1LL<<k); if(y < x && y >= 0){ dp[i]++; break; } while((1LL<<k)*x > y) k--; } //if(i < a.size())sum += a[i]*p; } return dp[K-1]; } int main() { int q; assert(scanf("%d", &q) == 1); vector<int> k(q); vector<long long> x(q); vector<vector<long long>> a(q); vector<long long> results(q); for (int t = 0; t < q; t++) { assert(scanf("%d%lld", &k[t], &x[t]) == 2); a[t] = vector<long long>(k[t]); for (int i = 0; i < k[t]; i++) { assert(scanf("%lld", &a[t][i]) == 1); } } fclose(stdin); for (int t = 0; t < q; t++) { results[t] = count_tastiness(x[t], a[t]); } for (int t = 0; t < q; t++) { printf("%lld\n", results[t]); } fclose(stdout); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:17:8: warning: unused variable 'sum' [-Wunused-variable]
   17 |     ll sum = a[0];
      |        ^~~
/tmp/ccgMQakR.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccnGmmPU.o:biscuits.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status