Submission #1041664

#TimeUsernameProblemLanguageResultExecution timeMemory
1041664inkvizytorRice Hub (IOI11_ricehub)C++17
100 / 100
10 ms4532 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...