Submission #49754

#TimeUsernameProblemLanguageResultExecution timeMemory
49754gs13105Rice Hub (IOI11_ricehub)C++17
49 / 100
32 ms1020 KiB
#include <cstdio> #include <cstdlib> #include <cstring> #include <cassert> #include <iostream> #include <algorithm> #include <string> #include <vector> #include <list> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <tuple> #include <iterator> //#include "ricehub.h" using namespace std; int besthub(int R, int L, int X[], long long B) { int p = 0, q = 0, res = 0; long long c = 0; for(int i = 0; i < R; i++) { if(i) c += 1LL * ((i - p) - (q - i)) * (X[i] - X[i - 1]); while(c > B) { assert(p < R); c -= X[i] - X[p++]; } while(q < R && (X[q] - X[i] <= X[i] - X[p] || c + X[q] - X[i] <= B)) { c += X[q++] - X[i]; if(c > B) { assert(p < R); c -= X[i] - X[p++]; assert(c <= B); } } assert(c <= B); res = max(res, q - p); } 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...