답안 #28883

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28883 2017-07-17T12:01:58 Z inqr 쌀 창고 (IOI11_ricehub) C++14
68 / 100
1000 ms 5924 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B)
// R toplam pirinc tarlasi sayisi
// L yolun uzunlugu
// X[] pirinc tarlalarinin kordinatlari
// B harciyabilecegin maksimum para
// optimal cozum her zaman bir tarlanin uzerinde
{
	int ans=0;
	for(int i=0;i<R;i++){
		int count=1;long long cost=0;
		int l=i-1,r=i+1;
		while(X[i]==X[i+1]){
			count++;
			i++;
			r++;
		}
		while(cost <= B ){
			int ll=INT_MAX,rr=INT_MAX;
			if(0<=l and cost+(X[i]-X[l])<=B)ll=(X[i]-X[l]);
			if(r<R  and cost+(X[r]-X[i])<=B)rr=(X[r]-X[i]);
			if(ll<=rr and ll!=INT_MAX){
				count++;
				cost+=ll;
				l--;
			}
			else if(rr<ll and rr!=INT_MAX){
				count++;
				cost+=rr;
				r++;
			}
			else break;
		}
		ans=max(ans,count);
	}
  	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5924 KB Output is correct
2 Correct 0 ms 5924 KB Output is correct
3 Correct 0 ms 5924 KB Output is correct
4 Correct 0 ms 5924 KB Output is correct
5 Correct 0 ms 5924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5924 KB Output is correct
2 Correct 0 ms 5924 KB Output is correct
3 Correct 0 ms 5924 KB Output is correct
4 Correct 0 ms 5924 KB Output is correct
5 Correct 0 ms 5924 KB Output is correct
6 Correct 0 ms 5924 KB Output is correct
7 Correct 0 ms 5924 KB Output is correct
8 Correct 0 ms 5924 KB Output is correct
9 Correct 0 ms 5924 KB Output is correct
10 Correct 0 ms 5924 KB Output is correct
11 Correct 0 ms 5924 KB Output is correct
12 Correct 0 ms 5924 KB Output is correct
13 Correct 0 ms 5924 KB Output is correct
14 Correct 0 ms 5924 KB Output is correct
15 Correct 0 ms 5924 KB Output is correct
16 Correct 0 ms 5924 KB Output is correct
17 Correct 0 ms 5924 KB Output is correct
18 Correct 0 ms 5924 KB Output is correct
19 Correct 0 ms 5924 KB Output is correct
20 Correct 0 ms 5924 KB Output is correct
21 Correct 0 ms 5924 KB Output is correct
22 Correct 0 ms 5924 KB Output is correct
23 Correct 0 ms 5924 KB Output is correct
24 Correct 0 ms 5924 KB Output is correct
25 Correct 0 ms 5924 KB Output is correct
26 Correct 0 ms 5924 KB Output is correct
27 Correct 0 ms 5924 KB Output is correct
28 Correct 0 ms 5924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5924 KB Output is correct
2 Correct 0 ms 5924 KB Output is correct
3 Correct 3 ms 5924 KB Output is correct
4 Correct 0 ms 5924 KB Output is correct
5 Correct 0 ms 5924 KB Output is correct
6 Correct 0 ms 5924 KB Output is correct
7 Correct 0 ms 5924 KB Output is correct
8 Correct 0 ms 5924 KB Output is correct
9 Correct 0 ms 5924 KB Output is correct
10 Correct 0 ms 5924 KB Output is correct
11 Correct 0 ms 5924 KB Output is correct
12 Correct 0 ms 5924 KB Output is correct
13 Correct 3 ms 5924 KB Output is correct
14 Correct 0 ms 5924 KB Output is correct
15 Correct 0 ms 5924 KB Output is correct
16 Correct 0 ms 5924 KB Output is correct
17 Correct 3 ms 5924 KB Output is correct
18 Correct 3 ms 5924 KB Output is correct
19 Correct 6 ms 5924 KB Output is correct
20 Correct 6 ms 5924 KB Output is correct
21 Correct 0 ms 5924 KB Output is correct
22 Correct 0 ms 5924 KB Output is correct
23 Correct 56 ms 5924 KB Output is correct
24 Correct 53 ms 5924 KB Output is correct
25 Correct 126 ms 5924 KB Output is correct
26 Correct 146 ms 5924 KB Output is correct
27 Correct 69 ms 5924 KB Output is correct
28 Correct 43 ms 5924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 5924 KB Output is correct
2 Correct 13 ms 5924 KB Output is correct
3 Execution timed out 1000 ms 5924 KB Execution timed out
4 Halted 0 ms 0 KB -