Submission #28877

# Submission time Handle Problem Language Result Execution time Memory
28877 2017-07-17T11:51:00 Z aybala Rice Hub (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;
            ^
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -