Submission #871712

#TimeUsernameProblemLanguageResultExecution timeMemory
871712dsyz쌀 창고 (IOI11_ricehub)C++17
68 / 100
1087 ms3676 KiB
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; using ll = long long; #define MAXN (1000005) int besthub(int R, int L, int X[], long long B){ ll maximum = 0; for(ll pos = 0;pos < R;pos++){ ll Lptr = pos; ll Rptr = pos; ll curcost = 0; while(Lptr > 0 && curcost + abs(X[pos] - X[Lptr - 1]) <= B){ curcost += abs(X[pos] - X[Lptr - 1]); Lptr--; } while(Rptr < R - 1 && curcost + abs(X[pos] - X[Rptr + 1]) <= B){ curcost += abs(X[pos] - X[Rptr + 1]); Rptr++; } while(Rptr < R - 1 && abs(X[pos] - X[Lptr]) > abs(X[pos] - X[Rptr + 1])){ curcost -= abs(X[pos] - X[Lptr]); curcost += abs(X[pos] - X[Rptr + 1]); Lptr++; Rptr++; while(Rptr < R - 1 && curcost + abs(X[pos] - X[Rptr + 1]) <= B){ curcost += abs(X[pos] - X[Rptr + 1]); Rptr++; } } maximum = max(maximum,Rptr - Lptr + 1); } return maximum; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...