답안 #872499

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
872499 2023-11-13T08:31:47 Z StefanL2005 쌀 창고 (IOI11_ricehub) C++14
68 / 100
134 ms 4444 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
#define ll long long

int solve(int poz, int R, int B, vector<int> &X)
{
    int c1 = poz - 1, c2 = poz + 1;
    bool done_change = true;
    int nr = 1;
    while (done_change)
    {
        done_change = false;
        if (c1 < 0 && c2 >= R)
            break;

        if (c1 >= 0 && (c2 >= R || X[poz] - X[c1] <= X[c2] - X[poz]))
        {
            nr++; done_change = true;
            B -= (X[poz] - X[c1]);
            c1--;
        }
        else
            if (c2 < R && (c1 < 0 || X[c2] - X[poz] < X[poz] - X[c1]))
            {
                nr++; done_change = true;
                B -= (X[c2] - X[poz]);
                c2++;
            }

        if (B < 0)
        {
            nr--;
            done_change = false;
        }
    }
    return nr;
}
int besthub(int R, int L, int V[], ll B)
{
    vector<int> X(R);
    for (int i = 0; i < R; i++)
        X[i] = V[i];
    /*vector<ll> dp(R);
    for (int i = 1; i < R; i++)
        dp[0] += (X[i] - X[0]);

    ll sum = dp[0];
    int right = R, left = 0;
    for (int i = 1; i < R; i++)
    {
        right--;
        left++;
        if (X[i] == X[i - 1])
        {
            dp[i] = dp[i - 1];
            continue;
        }

        int dif = X[i] - X[i - 1];

        sum = sum - dif * right + dif * left;
        dp[i] = sum;
    }

    ll Min = dp[0]; int poz = 0;
    for (int i = 0; i < R; i++)
        if (dp[i] < Min)
        {
            Min = dp[i];
            poz = i;
        }
    */
    vector<int> best(R);
    for (int i = 0; i < R; i++)
        best[i] = solve(i, R, B, X);
    int Max = best[0];
    for (int i = 0; i < R; i++)
        Max = max(Max, best[i]);
    return Max;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 452 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 0 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 1 ms 444 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 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 452 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 452 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 600 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 452 KB Output is correct
14 Correct 3 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 3 ms 344 KB Output is correct
18 Correct 3 ms 348 KB Output is correct
19 Correct 5 ms 456 KB Output is correct
20 Correct 4 ms 348 KB Output is correct
21 Correct 3 ms 348 KB Output is correct
22 Correct 3 ms 456 KB Output is correct
23 Correct 43 ms 348 KB Output is correct
24 Correct 38 ms 512 KB Output is correct
25 Correct 94 ms 520 KB Output is correct
26 Correct 91 ms 516 KB Output is correct
27 Correct 27 ms 348 KB Output is correct
28 Correct 34 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 600 KB Output is correct
2 Correct 5 ms 600 KB Output is correct
3 Incorrect 134 ms 4444 KB Output isn't correct
4 Halted 0 ms 0 KB -