Submission #289702

#TimeUsernameProblemLanguageResultExecution timeMemory
289702b00n0rp쌀 창고 (IOI11_ricehub)C++17
100 / 100
21 ms3328 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set; typedef long long ll; typedef vector <int> vi; typedef vector<vi> vvi; typedef map<int,int> mii; typedef pair<int,int> pii; #define pb push_back #define INF 1000000000 #define mp make_pair #define MOD 1000000007 #define F first #define S second const double PI=3.14159265358979323846264338327950288419716939937510582097494459230; #define REP(i,n) for(int i=0;i<(n);i++) #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REPD(i,n) for(int i=(n);i>=0;i--) #define FORD(i,a,b) for(int i=(a);i>=b;i--) #define all(v) v.begin(),v.end() #define itr ::iterator it; #define WL(t) while(t --) ll r,l,b; ll a[1000005]; ll pref[1000005]; ll ans = 0; ll cost(ll s, ll e){ // s -> start e -> end m -> mid ll m = (s+e)/2; return (a[m]*(m-s))-(pref[m]-pref[s])+(pref[e+1]-pref[m+1])-(a[m]*(e-m)); } ll besthub(int R, int L, int X[], ll B){ r = R; l = L; b = B; pref[0] = 0; REP(i,r){ a[i] = X[i]; pref[i+1] = pref[i]+a[i]; } ll low = 0,high = 0; while (high < r){ ll cur = cost(low,high); // cout << low << " " << high << " " << cur << endl; if (cur <= b){ ans = max(ans,high-low+1); high ++; } else{ low ++; } } 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...