제출 #1041065

#제출 시각아이디문제언어결과실행 시간메모리
1041065inkvizytorRice Hub (IOI11_ricehub)C++17
25 / 100
8 ms4448 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 = 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...