Submission #28869

# Submission time Handle Problem Language Result Execution time Memory
28869 2017-07-17T11:27:51 Z aybala Rice Hub (IOI11_ricehub) C++11
0 / 100
23 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--){
			if(xx[j]!=0){
				top+=(long long)(i-j)*xx[j];
				say+=xx[j];	
				if(top<=B && say>ans)
					ans=say;
			}
			for(k=i;k<=L;k++){
				if(xx[k]!=0){
					top+=(long long)(k-i)*xx[k];
					say+=xx[k];		
					if(top<=B && say>ans)
						ans=say;
				}
				
			}
			top=0,say=0;
		}
		
		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:5:12: warning: unused variable 'l' [-Wunused-variable]
  int i,j,k,l;
            ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5020 KB Output is correct
2 Incorrect 0 ms 5020 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 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 Runtime error 23 ms 5020 KB Execution killed because of forbidden syscall writev (20)
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 -