답안 #735090

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
735090 2023-05-03T14:10:03 Z tigar 쌀 창고 (IOI11_ricehub) C++14
68 / 100
18 ms 2508 KB
#include <bits/stdc++.h>
#include "ricehub.h"

using namespace std;
typedef long long ll;
ll prefs[100010];

ll cost(int l, int r, int *x)
{
    int m=(l+r)/2;
    return prefs[r+1]-prefs[m+1]-(r-m)*x[m]-prefs[m]+prefs[l]+(m-l)*x[m];
}

int besthub(int R, int L, int *X, ll B)
{
    prefs[0]=0;
    for(int i=1; i<=R; i++)prefs[i]=prefs[i-1]+X[i-1];
    ll k=0, ans=0;
    for(int i=0; i<R; i++)
    {
        while(cost(k, i, X)>B and k<i)k++;
        //cout<<cost(k, i, X)<<endl;;
        ans=max(i-k+1, ans);
    }
    //cout <<cost(0, 4, X)<<endl;
    return ans;
}

/*int main()
{
    int r, l, x[100010];
    ll b;
    cin>>r>>l>>b;
    for(int i=0; i<r; i++)cin>>x[i];
    //cin>>b;
    cout<<besthub(r, l, x, b);
    return 0;
}*/
# 결과 실행 시간 메모리 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 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 308 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 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 212 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 308 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 308 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 316 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 308 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 316 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 324 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 596 KB Output is correct
2 Correct 3 ms 576 KB Output is correct
3 Correct 12 ms 1620 KB Output is correct
4 Correct 12 ms 1556 KB Output is correct
5 Correct 6 ms 1236 KB Output is correct
6 Correct 7 ms 1236 KB Output is correct
7 Correct 12 ms 2152 KB Output is correct
8 Correct 18 ms 2132 KB Output is correct
9 Correct 6 ms 1108 KB Output is correct
10 Correct 6 ms 1108 KB Output is correct
11 Correct 18 ms 2472 KB Output is correct
12 Correct 16 ms 2508 KB Output is correct
13 Correct 6 ms 1196 KB Output is correct
14 Correct 6 ms 1256 KB Output is correct
15 Correct 9 ms 1856 KB Output is correct
16 Correct 10 ms 1880 KB Output is correct
17 Correct 16 ms 2232 KB Output is correct
18 Incorrect 13 ms 2240 KB Output isn't correct
19 Halted 0 ms 0 KB -