Submission #1070924

#TimeUsernameProblemLanguageResultExecution timeMemory
1070924mariaclaraPacking Biscuits (IOI20_biscuits)C++17
9 / 100
1057 ms243356 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); multiset<ll> dp; dp.insert(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 = (x << i) - to_add; if((x << i) > 2e18) break; for(auto ptr = dp.lower_bound(val); ptr != dp.end(); ptr++) { // dp[i][j] = guarda quantos números eu posso formar dp.insert(*ptr - (x<<i)); } } 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...