답안 #741139

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
741139 2023-05-13T15:48:34 Z LCJLY 쌀 창고 (IOI11_ricehub) C++14
68 / 100
14 ms 1876 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;

int besthub(int R, int L, int X[], long long B)
{
	int n=R,k=L;
	int arr[n+5];
	for(int x=0;x<n;x++){
		arr[x+1]=X[x];
	}	
	
	long long psum[n+5];
	for(int x=1;x<=n;x++){
		psum[x]=psum[x-1]+arr[x];
	}
	
	int l=1;
	int ans=0;
	
	for(int x=1;x<=n;x++){
		while(l<x){
			int mid=(l+x)/2;
			long long cost=arr[mid]*(mid-l)-(psum[mid-1]-psum[l-1])+(psum[x]-psum[mid])-arr[mid]*(x-mid);
			
			if(cost>B){
				l++;
			}
			else{
				break;
			}
		}
		ans=max(ans,x-l+1);
	}
	
	return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:8:10: warning: unused variable 'k' [-Wunused-variable]
    8 |  int n=R,k=L;
      |          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 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 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 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
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 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 212 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 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 2 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 2 ms 596 KB Output is correct
3 Correct 12 ms 1792 KB Output is correct
4 Correct 13 ms 1768 KB Output is correct
5 Correct 6 ms 980 KB Output is correct
6 Correct 6 ms 980 KB Output is correct
7 Correct 14 ms 1748 KB Output is correct
8 Correct 11 ms 1748 KB Output is correct
9 Correct 5 ms 980 KB Output is correct
10 Correct 6 ms 980 KB Output is correct
11 Correct 12 ms 1876 KB Output is correct
12 Correct 13 ms 1876 KB Output is correct
13 Correct 6 ms 980 KB Output is correct
14 Correct 6 ms 1008 KB Output is correct
15 Correct 10 ms 1364 KB Output is correct
16 Correct 9 ms 1364 KB Output is correct
17 Correct 11 ms 1620 KB Output is correct
18 Incorrect 12 ms 1620 KB Output isn't correct
19 Halted 0 ms 0 KB -