(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #615970

#TimeUsernameProblemLanguageResultExecution timeMemory
615970fvogel499Packing Biscuits (IOI20_biscuits)C++17
100 / 100
21 ms1244 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; #define vi vector<int> #define int long long #define pb push_back #define ins insert #define sz(x) (int)((x).size()) long long count_tastiness(long long x, std::vector<long long> b) { while (sz(b) < 60) b.push_back(0); int lim [60+1]; int sum = 0; for (int i = 0; i < 60; i++) { sum += (1LL<<i)*b[i]; lim[i] = min(sum/x, (1LL<<(i+1))-1); } lim[60] = (1LL<<60)-1; int dp [60][60+1]; for (int i = 0; i <= 60; i++) { if (lim[0] == 0 || (lim[i]&1) == 0) { dp[0][i] = 1; } else { dp[0][i] = 2; } } for (int i = 1; i < 60; i++) for (int j = 0; j <= 60; j++) { int resultingMask = (1LL<<(i))-1; dp[i][j] = 0; if (((lim[i]>>i)&1) && ((lim[j]>>i)&1)) { int newJ = j; if ((lim[i]&resultingMask) < (lim[j]&resultingMask)) { newJ = i; } dp[i][j] += dp[i-1][newJ]; // add one dp[i][j] += dp[i-1][60]; // add zero } else if (!((lim[i]>>i)&1) && !((lim[j]>>i)&1)) { int newJ = j; if ((lim[i]&resultingMask) < (lim[j]&resultingMask)) { newJ = i; } dp[i][j] += dp[i-1][newJ]; // add zero } else if ((lim[i]>>i)&1) { dp[i][j] += dp[i-1][j]; } else { dp[i][j] += dp[i-1][i]; } } int res = dp[60-1][60]; return res; }
#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...