This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B) {
vector<long long> dp (R+1, 0);
for (int i = 0; i < R; i++) {
dp[i+1] = dp[i]+X[i];
}
long long poc=1, kon=1;
long long score = 0;
while (kon <= R) {
int sr = (poc+kon)/2;
if (!((kon-poc)%2)) {
long long s = dp[kon]-dp[sr]-dp[sr-1]+dp[poc-1];
if (s <= B) {
score = max(score, kon-poc+1);
kon++;
}
else {
poc++;
}
}
else {
long long s = dp[kon]-dp[sr]*2+dp[poc-1];
if (s <= B) {
score = max(score, kon-poc+1);
kon++;
}
else {
poc++;
}
}
}
return score;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |