답안 #398494

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
398494 2021-05-04T11:48:44 Z iulia13 쌀 창고 (IOI11_ricehub) C++14
100 / 100
19 ms 1484 KB
#include <iostream>
#include <vector>
#include "ricehub.h"
using namespace std;
const int nmax = 1e5 + 5;
#define ll long long
ll pref[nmax];
ll suf[nmax];
int besthub(int n, int l, int v[], ll b)
{
    int i;
    for (i = 0; i < n; i++)
        pref[i] = pref[i - 1] + 1ll * v[i];
    int st = 1, dr = n, sol = 0;
    while (st <= dr)
    {
        int mid = (st + dr) / 2, ok = 1;
        for (i = 0; ok && i < n - mid + 1; i++)
        {
            ///de la i la i + mid - 1
            int poz = (2 * i + mid - 1) / 2;
            ll money = 1ll * (poz - i) * v[poz] - 1ll * (i + mid - 1 - poz) * v[poz];
            money -= (pref[poz - 1] - pref[i - 1]);
            money += pref[i + mid - 1] - pref[poz];
            if (money <= b)
                ok = 0;
        }
        if (!ok)
        {
            sol = mid;
            st = mid + 1;
        }
        else
            dr = mid - 1;
    }
    return sol;
}/*
int dani[nmax];
int main()
{
    int r, l; ll b;
    cin >> r >> l >> b;
    for (int i = 0; i < r; i++)
        cin >> dani[i];

    //cin >> b;
    cout << besthub(r, l, dani, b);
    return 0;
}*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 308 KB Output is correct
20 Correct 1 ms 300 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 356 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 460 KB Output is correct
2 Correct 4 ms 460 KB Output is correct
3 Correct 16 ms 1364 KB Output is correct
4 Correct 16 ms 1444 KB Output is correct
5 Correct 8 ms 864 KB Output is correct
6 Correct 10 ms 844 KB Output is correct
7 Correct 14 ms 1484 KB Output is correct
8 Correct 14 ms 1372 KB Output is correct
9 Correct 12 ms 808 KB Output is correct
10 Correct 11 ms 848 KB Output is correct
11 Correct 15 ms 1356 KB Output is correct
12 Correct 16 ms 1484 KB Output is correct
13 Correct 9 ms 844 KB Output is correct
14 Correct 9 ms 888 KB Output is correct
15 Correct 13 ms 1100 KB Output is correct
16 Correct 12 ms 1116 KB Output is correct
17 Correct 14 ms 1280 KB Output is correct
18 Correct 19 ms 1352 KB Output is correct
19 Correct 15 ms 1356 KB Output is correct
20 Correct 15 ms 1336 KB Output is correct