Submission #1086951

#TimeUsernameProblemLanguageResultExecution timeMemory
1086951MrPavlitoRice Hub (IOI11_ricehub)C++17
17 / 100
9 ms860 KiB
#include "ricehub.h" #include <bits/stdc++.h> //#define int long long #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define fi first #define sc second #define endl "\n" #define pii pair<int,int> using namespace std; const int MAXN = 1e5+5; const int mod7 = 1e9+7; const long long inf = 1e18; int n; int besthub(int R, int L, int X[], long long B) { n = R; int l = 0;int r =1; int i =0; long long trsum = 0; int cntr = 0; int cntl =0; int mx = 0; while(r<n) { while(r<n) { if(trsum+ X[r] - X[i] <= B) { trsum+= X[r++] - X[i]; cntr++; } else if(i<l && X[r] - X[i] < X[i] - X[l] && trsum+ (X[r] - X[i]) - (X[i] - X[l]) <= B) { trsum -= (X[i] - X[l]); trsum += (X[r] - X[i]); l++; r++; } else if(trsum >= B && l<i) { cntl--; trsum -= (X[i] - X[l++]); } else break; } mx = max(mx, r-l); i++; trsum += (i-l) *1ll * (X[i] - X[i-1]); trsum -= (r-i) *1ll * (X[i] - X[i-1]); } return mx; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...