답안 #716582

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
716582 2023-03-30T13:00:43 Z Jarif_Rahman 쌀 창고 (IOI11_ricehub) C++17
0 / 100
16 ms 2508 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

int besthub(int n, int L, int X[], long long B){
    vector<ll> pref(n, 0);
    for(int i = 0; i < n; i++){
        if(i) pref[i] = pref[i-1];
        pref[i]+=X[i];
    }

    auto sum = [&](int l, int r){
        return pref[r]-(l?pref[l-1]:0);
    };

    int ans = 0;
    for(int i = 0; i < n; i++){
        int c = min(i, n-i-1);
        int a = 1, b = c;
        while(a < b){
            int md = (a+b+1)/2;
            if(sum(i+1, i+c)-sum(i-c, i-1) <= B) a = md;
            else b = md-1;
        }
        if(c == 0) a = 0;

        if(sum(i+1, i+a)-sum(i-a, i-1) <= B) ans = max(ans, 2*a+1);
        if(i+a+1 < n && sum(i+1, i+a+1)-sum(i-a, i-1)-X[i] <= B) ans = max(ans, 2*a+2);
    }

    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Incorrect 1 ms 212 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 636 KB Output is correct
2 Correct 3 ms 636 KB Output is correct
3 Correct 16 ms 2508 KB Output is correct
4 Correct 14 ms 2504 KB Output is correct
5 Correct 6 ms 1196 KB Output is correct
6 Correct 7 ms 1236 KB Output is correct
7 Correct 11 ms 2124 KB Output is correct
8 Correct 13 ms 2276 KB Output is correct
9 Correct 7 ms 1108 KB Output is correct
10 Correct 7 ms 1108 KB Output is correct
11 Correct 16 ms 2508 KB Output is correct
12 Correct 14 ms 2472 KB Output is correct
13 Incorrect 7 ms 1240 KB Output isn't correct
14 Halted 0 ms 0 KB -