Submission #1074254

#TimeUsernameProblemLanguageResultExecution timeMemory
1074254dostsRice Hub (IOI11_ricehub)C++17
0 / 100
55 ms1372 KiB
#include "ricehub.h" //Dost SEFEROĞLU #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define int long long #define os tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> #define inr int32_t #define pii pair<int,int> #define ff first #define ss second #define sp << " " << #define all(cont) cont.begin(),cont.end() #define vi vector<int> inr besthub(inr R, inr L, inr X[], long long B) { vi p(R+1,0); for (int i=1;i<=R;i++) p[i] = p[i-1]+X[i-1]; int l = 1; int r = R; while (l<=r) { int m = (l+r) >> 1; os oset; for (int j=1;j<=m-1;j++) { oset.insert({X[j-1],j-1}); } bool fl = 0; for (int j=m;j<=R;j++) { oset.insert({X[j-1],j}); int med = oset.find_by_order(m/2)->first; int medidx = j-m+m/2; int sag = (p[j]-p[medidx-1])-med*(j-medidx+1); int sol = med*(medidx-(j-m+1)+1)-(p[medidx]-p[j-m]); if(sol+sag <= B) fl = 1; oset.erase(oset.begin()); } if (fl) l = m+1; else r = m-1; } return r; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...