Submission #206914

#TimeUsernameProblemLanguageResultExecution timeMemory
206914jasony123123Rice Hub (IOI11_ricehub)C++11
100 / 100
25 ms1784 KiB
#include "ricehub.h" #include <bits/stdc++.h> //#include <ext/pb_ds/tree_policy.hpp> //#include <ext/pb_ds/assoc_container.hpp> using namespace std; //using namespace __gnu_pbds; #define FOR(i,start,end) for(int i=start;i<(int)(end);i++) #define FORE(i,start,end) for(int i=start;i<=(int)end;i++) #define RFORE(i,start,end) for(int i = start; i>=end; i--) #define all(a) a.begin(), a.end() #define v vector typedef long long ll; typedef pair<int, int > pii; //template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template<class T> void minn(T &a, T b) { a = min(a, b); } template<class T> void maxx(T &a, T b) { a = max(a, b); } ll P[100000]; #define num(a,b) ((ll)((b)-(a)+1)) #define sum(a,b) ((ll)(P[b]-(a-1<0?0:P[a-1]))) ll cost(int l, int r){ // cout << "cost "<< l << " to " << r << endl; int m = (l+r)/2; // cout << "m = " << m << endl; // cout << "num(m+1,r) " << m+1 << " " << r << " " << num(m+1,r) << endl; // printf("sum(m+1,r,%d)-num(m+1,r,%d)*sum(m,m,%d)+num(l,m,%d)*sum(m,m,%d)-sum(l,m,%d)\n", sum(m+1,r), num(m+1,r), sum(m,m), num(l,m), sum(m,m), sum(l,m)); return sum(m+1,r)-num(m+1,r)*sum(m,m)+num(l,m)*sum(m,m)-sum(l,m); } int besthub(int R, int L, int X[], long long B){ P[0] = X[0]; FOR(i,1,R) P[i] = X[i]+P[i-1]; int ans = 0; for(int i = 0, j = -1; i < R; i++){ while(j+1 < R && cost(i,j+1) <= B) j++; assert(i<=j); maxx(ans, j-i+1); } // FOR(i,0,R) cout << "x " << X[i] << endl; // cout << "budget " << B << endl; // FOR(i,0,R) cout << "p " << P[i] << endl; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...