답안 #133032

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
133032 2019-07-20T05:30:21 Z Boxworld 쌀 창고 (IOI11_ricehub) C++14
100 / 100
21 ms 2424 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
const int maxN=100100;
long long S[maxN],x[maxN];
int besthub(int R, int L, int X[], long long B){
	S[0]=0;x[0]=0;
	for (int i=1;i<=R;i++){
		x[i]=X[i-1];
		S[i]=S[i-1]+X[i-1];
	}
	int l,r,ans=1;
	for (int l=1;l<=R;l++)
	for (int r=l+ans;r<=R;r++){
		int m=(l+r)/2;
		long long cost=(m-l)*x[m]-(S[m-1]-S[l-1])+S[r]-S[m]-(r-m)*x[m];
		if(cost<=B)ans=max(ans,r-l+1);
		else break;
	}
	return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:12:6: warning: unused variable 'l' [-Wunused-variable]
  int l,r,ans=1;
      ^
ricehub.cpp:12:8: warning: unused variable 'r' [-Wunused-variable]
  int l,r,ans=1;
        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 252 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
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 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 3 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 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 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 3 ms 400 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 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 504 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 760 KB Output is correct
2 Correct 5 ms 760 KB Output is correct
3 Correct 19 ms 2296 KB Output is correct
4 Correct 19 ms 2424 KB Output is correct
5 Correct 9 ms 1400 KB Output is correct
6 Correct 9 ms 1400 KB Output is correct
7 Correct 16 ms 2332 KB Output is correct
8 Correct 16 ms 2408 KB Output is correct
9 Correct 8 ms 1392 KB Output is correct
10 Correct 8 ms 1400 KB Output is correct
11 Correct 21 ms 2416 KB Output is correct
12 Correct 21 ms 2424 KB Output is correct
13 Correct 10 ms 1400 KB Output is correct
14 Correct 10 ms 1400 KB Output is correct
15 Correct 16 ms 1828 KB Output is correct
16 Correct 17 ms 2040 KB Output is correct
17 Correct 19 ms 2168 KB Output is correct
18 Correct 19 ms 2168 KB Output is correct
19 Correct 20 ms 2384 KB Output is correct
20 Correct 20 ms 2268 KB Output is correct