Submission #304770

#TimeUsernameProblemLanguageResultExecution timeMemory
304770junseoPacking Biscuits (IOI20_biscuits)C++17
44 / 100
111 ms3584 KiB
#include "biscuits.h" #include <bits/stdc++.h> #define fi first #define se second #define eb emplace_back #define all(v) (v).begin(), (v).end() #define rmin(r, x) r = min(r, x) #define rmax(r, x) r = max(r, x) #define ends ' ' #define endl '\n' #define fastio ios_base::sync_with_stdio(0), cin.tie(0) #pragma GCC optimize("O3") #pragma GCC target("avx,avx2") using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int maxk = 65; const int maxa = 2e5 + 10; int k; ll s[maxk], ans[maxa]; long long count_tastiness(long long x, std::vector<long long> a) { k = a.size(); a.resize(maxk); s[0] = a[0]; for(int i = 1; i <= 60; ++i) s[i] = s[i - 1] + (1LL << i) * a[i]; int N = 1; for(int i = 0; i <= 60; ++i) { int st = 1, ed = N, r = 0; ll T = s[i] / x - (1LL << i); while(st <= ed) { int mid = st + ed >> 1; if(T >= ans[mid]) { r = mid; st = mid + 1; } else ed = mid - 1; } for(int j = 1; j <= r; ++j) { ans[++N] = ans[j] + (1LL << i); } } assert(N <= 2e5); return N; }

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:36:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   36 |    int mid = st + ed >> 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...