답안 #145023

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
145023 2019-08-18T12:49:24 Z mhy908 쌀 창고 (IOI11_ricehub) C++14
100 / 100
42 ms 2936 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
typedef long long LL;
LL sum[100010];
int arr[100010];
int ans=1;
int besthub(int n, int m, int x[], LL b)
{
    int l=1, r;
    LL p=0;
    for(int i=0; i<n; i++)arr[i+1]=x[i];
    for(int i=1; i<=n; i++)sum[i]=sum[i-1]+(LL)arr[i];
    for(r=1; r<=n; r++){
        while(l<=r){
            int mid=(l+r)/2;
            LL temp=(LL)(mid-l+1)*(LL)arr[mid]-(LL)(sum[mid]-sum[l-1])+(LL)(sum[r]-sum[mid-1])-(LL)(r-mid+1)*(LL)arr[mid];
            if(temp<=b){
                ans=max(ans, r-l+1);
                break;
            }
            l++;
        }
    }
    return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, LL)':
ricehub.cpp:11:8: warning: unused variable 'p' [-Wunused-variable]
     LL p=0;
        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 504 KB Output is correct
22 Correct 3 ms 504 KB Output is correct
23 Correct 3 ms 372 KB Output is correct
24 Correct 3 ms 504 KB Output is correct
25 Correct 3 ms 504 KB Output is correct
26 Correct 3 ms 504 KB Output is correct
27 Correct 3 ms 504 KB Output is correct
28 Correct 3 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 632 KB Output is correct
2 Correct 5 ms 796 KB Output is correct
3 Correct 42 ms 2908 KB Output is correct
4 Correct 19 ms 2936 KB Output is correct
5 Correct 9 ms 1528 KB Output is correct
6 Correct 9 ms 1528 KB Output is correct
7 Correct 16 ms 2652 KB Output is correct
8 Correct 16 ms 2680 KB Output is correct
9 Correct 9 ms 1400 KB Output is correct
10 Correct 9 ms 1400 KB Output is correct
11 Correct 20 ms 2936 KB Output is correct
12 Correct 20 ms 2936 KB Output is correct
13 Correct 10 ms 1528 KB Output is correct
14 Correct 10 ms 1528 KB Output is correct
15 Correct 16 ms 2296 KB Output is correct
16 Correct 17 ms 2296 KB Output is correct
17 Correct 20 ms 2684 KB Output is correct
18 Correct 18 ms 2680 KB Output is correct
19 Correct 19 ms 2812 KB Output is correct
20 Correct 19 ms 2808 KB Output is correct