Submission #434545

#TimeUsernameProblemLanguageResultExecution timeMemory
434545arayiPacking Biscuits (IOI20_biscuits)C++17
42 / 100
109 ms19328 KiB
#include "biscuits.h" #include <vector> #include <iostream> #include <algorithm> using namespace std; #define ad push_back #define lli long long lli dp[123][20110], x; vector<lli> a; lli rec(lli nx, int i) { if(i==a.size()) return 1; nx+=a[i]; if(nx >= x) return rec(nx/2,i+1)+rec((nx-x)/2,i+1); return rec(nx/2,i+1); } long long count_tastiness(long long x, std::vector<long long> a) { if(x <= 10000) { for (int i = 0; i <= 60; i++) a.ad(0); for (int i = 0; i < (int)a.size(); i++) for (int j = 0; j <= 2*x+100; j++) dp[i][j]=0; for (int i = 0; i < (int)a.size() - 1; i++) { a[i+1] += max(0LL, (a[i]-x)/2LL); a[i] -= max(0LL, (a[i]-x)/2)*2LL; } //for(auto p : a) cout << p << " "; cout << endl; dp[0][a[0]]=1; if(a[0]>=x) dp[0][a[0]-x]=1; for (int i = 1; i < (int)a.size(); i++) { for (int j = 0; j <= 2*x+100; j++) { if(dp[i-1][j]==0) continue; int sm = j/2; dp[i][sm+a[i]] += dp[i-1][j]; if(sm + a[i] >= x) dp[i][sm+a[i]-x] += dp[i-1][j]; } } lli ret = 0; for (int i = 0; i <= 2*x+100; i++) ret += dp[(int)a.size()-1][i]; return ret; } ::a=a; ::x=x; return rec(0,0); }

Compilation message (stderr)

biscuits.cpp: In function 'long long int rec(long long int, int)':
biscuits.cpp:14:6: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  if(i==a.size()) return 1;
      |     ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...