답안 #873810

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
873810 2023-11-15T20:18:53 Z StefanL2005 쌀 창고 (IOI11_ricehub) C++14
0 / 100
12 ms 4504 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
#define ll long long


int besthub(int R, int L, int V[], ll B)
{
    vector<int> X(R);
    vector<int> Best(R);
    for (int i = 0; i < R; i++)
        X[i] = V[i];

    int c1 = 0, c2 = 0;
    ll sum = 0;
    while (c2 < R && sum + X[c2] - X[0] <= B)
    {
        sum += X[c2] - X[0];
        c2++;
    }

    c2--;
    Best[0] = c2 + 1;

    for (int i = 1; i < R; i++)
    {
        if (X[i] == X[i - 1])
        {
            Best[i] = Best[i - 1];
            continue;
        }

        sum += (i - c1) * (X[i] - X[i - 1]) - (c2 - (i - 1)) * (X[i] - X[i - 1]);

        while (sum > B)
        {
            if (X[i] - X[c1] >= X[c2] - X[i])
            {
                sum -= X[i] - X[c1];
                c1++;
            }
            else
            {
                sum -= X[c2] - X[i];
                c2++;
            }
        } 

        while (c2 + 1 < R && X[c2 + 1] - X[i] < X[i] - X[c1])
        {
            sum += X[c2 + 1] - X[i];
            c2++;
            if (sum > B)
            {
                sum -= X[c1] - X[i];
                c1++;
            }
        }

        Best[i] = c2 - c1 + 1;
    }

    int Max = Best[0];
    for (int i = 0; i < R; i++)
        Max = max(Max, Best[i]);

    return Max;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 440 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 10 ms 4444 KB Output is correct
4 Correct 10 ms 4440 KB Output is correct
5 Correct 5 ms 3164 KB Output is correct
6 Correct 5 ms 3164 KB Output is correct
7 Correct 8 ms 4188 KB Output is correct
8 Correct 8 ms 4188 KB Output is correct
9 Correct 4 ms 3164 KB Output is correct
10 Correct 4 ms 3164 KB Output is correct
11 Correct 12 ms 4504 KB Output is correct
12 Incorrect 10 ms 4404 KB Output isn't correct
13 Halted 0 ms 0 KB -