답안 #28877

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28877 2017-07-17T11:51:00 Z aybala 쌀 창고 (IOI11_ricehub) C++11
17 / 100
443 ms 5020 KB
#include "ricehub.h"

int besthub(int R, int L, int X[], long long B)
{
	/*int i,j,k,l;
	int xx[103];
	for(i=1;i<=L;i++){
		xx[i]=0;
	}
	for(i=0;i<R;i++){
		xx[X[i]]++;
		
	}
	
	int ans=0;
	for(i=1;i<=L;i++){
		long long top=0,say=0;
		for(j=i-1;j>=1;j--){
			for(k=i;k<=L;k++){
				top=0,say=0;
				for(l=i; l>=j; l--){
						top+=(long long)(i-l)*xx[l];
						say+=xx[l];	
						
				}
				for(l=i; l<=k; l++){
						top+=(long long)(l-i)*xx[l];
						say+=xx[l];		
						
					
				}
				if(top<=B && say>ans)
							ans=say;
			}
			
		}
		
		if(top<=B && say>ans)
			ans=say;
	}*/
	
	int i,j,k,l;
	int ric[103];
	for(i=1;i<103;i++){
		ric[i]=0;
	}
	for(i=0;i<R;i++){
		ric[X[i]]++;
	}
	int ans=0,anss=0;
	for(i=1;i<=L;i++){
		for(j=i;j>=1;j--){
			for(k=i;k<=L;k++){
				long long top=0;
				int say=0;
				for(l=i-1;l>=j;l--){
					top+=(long long)(i-l)*ric[l];
					say+=ric[l];
					if(top>B)
						break;
				}
				for(l=i;l<=k;l++){
					top+=(long long)(l-i)*ric[l];
					say+=ric[l];
					if(top>B)
						break;
				}
				if(top<=B && say>ans){
					ans=say;
					
				}
			}
		}
	}
	R=ans;
	return R;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:50:12: warning: unused variable 'anss' [-Wunused-variable]
  int ans=0,anss=0;
            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5020 KB Output is correct
2 Correct 3 ms 5020 KB Output is correct
3 Correct 3 ms 5020 KB Output is correct
4 Correct 0 ms 5020 KB Output is correct
5 Correct 0 ms 5020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5020 KB Output is correct
2 Correct 0 ms 5020 KB Output is correct
3 Incorrect 443 ms 5020 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 5020 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 5020 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -