Submission #1064817

#TimeUsernameProblemLanguageResultExecution timeMemory
1064817thatsgonzalezPacking Biscuits (IOI20_biscuits)C++14
0 / 100
1059 ms5712 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; #define s second #define f first long long count_tastiness(long long x, std::vector<long long> a) { int k = a.size(); long long mp[20]; for(auto &y: mp) y=0; //for(auto &x: p) cout<<x<<" "; cout<<endl; long long s = 0; for(int i = 0; i<k; i++){ mp[i]+=a[i]; s+=a[i]*(1<<i); } //cout<<s<<endl; int ans = 0; int log = 0; while((1<<log)<=s) log++; long long need, pivot, dif; for(long long i = s; i>=0; i--){ long long used[20]; for(auto &y: used) y=0; bool band = true; for(long long j = (1<<log), q = log; j>0; j/=2, q--){ if((i&j)){ need = 0; for(long long c = q, h = 0; c>=0; c--, h++){ if(!mp[c]) continue; pivot = (1<<h); dif = mp[c]-used[c]; if(dif/pivot>=(x-need)){ used[c] += (x-need)*pivot; need = x; break; } else{ need += dif/pivot; used[c] += dif/pivot*pivot; } if(used[c]>mp[c]){ band = false; break; } } if(need != x) band = false; } } if(band) { cout<<i<<endl; for(auto &item: used) cout<<item<<" "; cout<<endl; ans++; } } return ans; }

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:57:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   57 |    for(auto &item: used) cout<<item<<" "; cout<<endl;
      |    ^~~
biscuits.cpp:57:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   57 |    for(auto &item: used) cout<<item<<" "; cout<<endl;
      |                                           ^~~~
#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...