Submission #235538

#TimeUsernameProblemLanguageResultExecution timeMemory
235538Toirov_SadiRice Hub (IOI11_ricehub)C++17
0 / 100
1093 ms528 KiB
#include<bits/stdc++.h> using namespace std; int besthub(int n, int L, int X[], long long B){ int res = 0; for(int i = 0; i < n; i ++){ int l = i, r = i; long long ans = 0; while(l >= 0 && r < n){ if(l > 0 && r < n - 1){ int x = X[i] - X[l - 1]; int y = X[r + 1] - X[i]; if(x < y && ans + x <= B){ l --; ans += x; } else if(y <= x && ans + y <= B){ r ++; ans += y; } } else if(l > 0 && ans + (X[i] - X[l - 1]) <= B){ ans += (X[i] - X[l - 1]); l --; } else if(r < n - 1 && ans + (X[r + 1] - X[i]) <= B){ ans += (X[r + 1] - X[i]); r ++; } else break; } res = max(res, r - l + 1); } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...