Submission #672761

#TimeUsernameProblemLanguageResultExecution timeMemory
672761tbzardPacking Biscuits (IOI20_biscuits)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; long long dp[210][10010]; long long count_tastiness(long long x, vector<long long> a){ memset(dp, 0, sizeof(dp)); vector<long long> b; long long sum = 0; for(int i=0;i<(int)a.size();i++){ sum += a[i]; if(sum > x) b.push_back(x), sum -= x; else b.push_back(sum), sum = 0; sum /= 2; } while(sum > 0){ if(sum > x) b.push_back(x), sum -= x; sum /= 2; } dp[0][0] = 1; for(int i=0;i<(int)b.size();i++){ for(int j=0;j<=10003;j++){ if(dp[i][j]){ dp[i+1][(j+b[i])/2] += dp[i][j]; if(j+b[i] >= x) dp[i+1][(j+b[i]-x)/2] += dp[i][j]; } } } long long ans = 0; for(int j=0;j<=10003;j++){ ans += dp[(int)b.size()][j]; } return ans; } int main(){ long long n, x; scanf("%lld%lld", &n, &x); vector<long long> a(n); for(int i=0;i<n;i++){ scanf("%lld", &a[i]); } printf("%lld\n", count_tastiness(n, a)); }

Compilation message (stderr)

biscuits.cpp: In function 'int main()':
biscuits.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     scanf("%lld%lld", &n, &x);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~
biscuits.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         scanf("%lld", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccFLR9tQ.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cckLm0VO.o:biscuits.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status