Submission #1007977

#TimeUsernameProblemLanguageResultExecution timeMemory
1007977North1304Rice Hub (IOI11_ricehub)C++14
100 / 100
8 ms3676 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 1; long long qs[N]; bool solve(int mid,int n,long long t) { long long l,r; for (int i=(mid+1)/2;i+mid/2<=n;i++) { if (mid%2) l = qs[i-1] - qs[max(0, i-mid/2-1)]; else l = qs[i] - qs[max(0, i-mid/2)]; r = qs[i+mid/2] - qs[i]; if (r - l <= t) return true; } return false; } int besthub(int n,int m,int x[],long long t) { for (int i=0;i<n;i++) qs[i+1] = qs[i] + x[i]; int l = 1 , r = n , ans = 0; while (l <= r) { int mid = (l + r) / 2; if (solve(mid, n, t)) l = mid + 1 , ans = mid; else r = mid - 1; } 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...