답안 #1005707

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005707 2024-06-22T20:50:11 Z ayankarimova 쌀 창고 (IOI11_ricehub) C++14
100 / 100
12 ms 3628 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
const ll sz=50005;
ll a[sz], b[sz], d[sz], p[sz];
int besthub(int num, int le, int x[], long long k)
{

    for(int i=0; i<num; i++){
        p[i+1]=p[i]+x[i];
    }
    ll l=1, r=1, ans=0;
    while(r<=num){
        ll mid=(l+r)/2, num;
        if((l+r)%2){
            ll num1=x[mid-1]*(mid-l)-p[mid-1]+p[l-1]+p[r]-p[mid]-x[mid-1]*(r-mid);
            mid++;
            ll num2=x[mid-1]*(mid-l)-p[mid-1]+p[l-1]+p[r]-p[mid]-x[mid-1]*(r-mid);
            num=min(num1, num2);
        }
        else num=x[mid-1]*(mid-l)-p[mid-1]+p[l-1]+p[r]-p[mid]-x[mid-1]*(r-mid);
        //cout<<l<<' '<<r<<' '<<num<<' '<<p[r-1]-p[mid-1]<<endl;
        if(num<=k){
            ans=max(ans, r-l+1);
            r++;
        }
        else{
            l++;
        }
    }
    return ans;
}
/*
{} []
5 20 6
1
2
10
12
14
3

1 3 13 25 39

12*2-10+39-13-12*1=12+16
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 0 ms 2396 KB Output is correct
25 Correct 0 ms 2396 KB Output is correct
26 Correct 0 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 0 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2496 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2500 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2652 KB Output is correct
2 Correct 2 ms 2392 KB Output is correct
3 Correct 8 ms 2648 KB Output is correct
4 Correct 8 ms 2492 KB Output is correct
5 Correct 4 ms 2496 KB Output is correct
6 Correct 4 ms 2652 KB Output is correct
7 Correct 6 ms 2488 KB Output is correct
8 Correct 7 ms 2652 KB Output is correct
9 Correct 3 ms 2488 KB Output is correct
10 Correct 3 ms 2652 KB Output is correct
11 Correct 8 ms 2492 KB Output is correct
12 Correct 7 ms 2652 KB Output is correct
13 Correct 3 ms 2652 KB Output is correct
14 Correct 6 ms 2904 KB Output is correct
15 Correct 6 ms 3240 KB Output is correct
16 Correct 7 ms 3416 KB Output is correct
17 Correct 7 ms 3416 KB Output is correct
18 Correct 7 ms 3368 KB Output is correct
19 Correct 12 ms 3628 KB Output is correct
20 Correct 8 ms 3496 KB Output is correct