Submission #1070944

#TimeUsernameProblemLanguageResultExecution timeMemory
1070944mariaclaraPacking Biscuits (IOI20_biscuits)C++17
0 / 100
1059 ms1051120 KiB
#include "biscuits.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define mk make_pair #define pb push_back #define fr first #define sc second ll count_tastiness(ll x, vector<ll> a) { int n = 60; ll sum = 0; while(sz(a) < 60) a.pb(0); for(int i = 0; i < n; i++) sum += a[i] * (1LL<<i); for(int i = 0; i < n-1; i++) { if(a[i] < x) continue; a[i+1] += (a[i] - x)/2; a[i] = x + ((a[i] - x)%2); } a[n-1] = min(a[n-1], x); vector<ll> dp; dp.pb(0); ll to_add = 0; for(int i = 0; i < n; i++) { // (val + to_add)/2^i >= x // val >= (x << i) - to_add to_add += (a[i] << i); ll val = to_add - (x << i); if((x << i) > 2e18) break; vector<ll> aux; for(auto y : dp) { // dp[i][j] = guarda quantos números eu posso formar if(y <= val) aux.pb((x<<i) - y); else break; } for(int j = sz(aux) - 1; j >= 0; j--) dp.pb(aux[j]); } return sz(dp); }
#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...