답안 #1005841

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005841 2024-06-23T06:55:38 Z hacizadal 쌀 창고 (IOI11_ricehub) C++17
0 / 100
8 ms 2652 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pll pair<ll, ll>

int besthub(int n, int l, int a[], long long b)
{
    // 0 1 2 3 4 5
    ll mid = a[n/2];
    if (n%2==0){
        mid += a[n/2+1];
        mid /= 2;
    }
    ll sum = 0, ind = -1, mx = 0;
    for (ll i = n/2+1; i<n; i++){
        sum += a[i];
        if (sum - (i-n/2)*mid <= b){
            ind = i;
            mx = max(mx, i-(n/2+1)+1);
        }
        else {
            sum -= a[i];
            break;
        }
    }
    //     24    4    2   10
    b -= (sum - (ind-n/2)*mid);
    ll sum2 = 0;
    for (ll i = n/2; i>=0; i--){
        sum2 += a[i];
        if ((n/2-i+1)*mid - sum2 <= b){
            mx = max(mx, ind-i+1);
        }
        else {
            b += (a[ind] - mid);
            ind--;
            if ((n/2-i+1)*mid - sum2 <= b){
                mx = max(mx, ind-i+1);
            }
            else {
                break;
            }
            if (ind == n/2) break;
        }
    }
    return mx;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 8 ms 2652 KB Output is correct
4 Correct 7 ms 2652 KB Output is correct
5 Correct 3 ms 2652 KB Output is correct
6 Correct 4 ms 2652 KB Output is correct
7 Correct 6 ms 2496 KB Output is correct
8 Correct 6 ms 2652 KB Output is correct
9 Correct 3 ms 2652 KB Output is correct
10 Correct 3 ms 2652 KB Output is correct
11 Correct 8 ms 2652 KB Output is correct
12 Correct 8 ms 2652 KB Output is correct
13 Incorrect 3 ms 2652 KB Output isn't correct
14 Halted 0 ms 0 KB -