Submission #1041656

#TimeUsernameProblemLanguageResultExecution timeMemory
1041656inkvizytorRice Hub (IOI11_ricehub)C++17
68 / 100
8 ms4440 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]; } int poc=1, kon=1; int score = 0; while (kon <= R) { int sr = (poc+kon)/2; if (!((kon-poc)%2)) { int s = dp[kon]-dp[sr]-dp[sr-1]+dp[poc-1]; if (s <= B) { score = max(score, kon-poc+1); kon++; } else { poc++; } } else { int 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...