Submission #28832

# Submission time Handle Problem Language Result Execution time Memory
28832 2017-07-17T09:32:20 Z dereotu Rice Hub (IOI11_ricehub) C++14
42 / 100
313 ms 6320 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define forr(i,A,B) for(int i=A;i<B;++i)
#define space ' '
#define endl '\n'
#define LL long long
using namespace std;

int a[100005],ans;
vector<pair<int,int> > arr;
//sonraki arrayi tutmayı denemelisin line 39
int besthub(int R, int L, int X[], long long B){
	if(L<=10000){
		forr(i,0,L){
			int b=0,h=0;
			memset(a,0,sizeof a);
			forr(j,0,R){
				a[j]=abs(X[j]-i);
			}
			sort(a,a+R);
			forr(j,0,R){
				if(b+a[j]<=B){
					b+=a[j];
					h++;
				}
				else break;
			}
			ans=max(ans,h);
		}
	 	return ans;
	 }
	 else{
	 	int b=0,left=0,right=0,ontop=0,h=0;
	 	forr(i,0,R){
	 		arr.clear();
	 		forr(j,0,R){
	 			arr[j].st=abs(X[j]-X[i]);
	 			if(X[j]-X[i]>0) arr[j].nd=1;
	 			else if(X[j]-X[i]<0) arr[j].nd=-1;
	 			else arr[j].nd=0;
	 		}
	 		sort(arr.begin(),arr.end());
	 		forr(j,0,R){
				if(b+arr[j].nd<=B){
					b+=arr[j].st;
					if(arr[j].nd==1) right++;
					else if(arr[j].nd==-1) left++;
					else ontop++;
					h++;
				}
				else break;
			}
			ans=max(ans,h);
			if(right-left>=2){
				i+=(right-left)/2;
				i--;
			}
	 	}
	 	return ans;
	 }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6320 KB Output is correct
2 Correct 0 ms 6320 KB Output is correct
3 Correct 0 ms 6320 KB Output is correct
4 Correct 3 ms 6320 KB Output is correct
5 Correct 0 ms 6320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6320 KB Output is correct
2 Correct 0 ms 6320 KB Output is correct
3 Correct 9 ms 6320 KB Output is correct
4 Correct 9 ms 6320 KB Output is correct
5 Correct 16 ms 6320 KB Output is correct
6 Correct 19 ms 6320 KB Output is correct
7 Correct 19 ms 6320 KB Output is correct
8 Correct 19 ms 6320 KB Output is correct
9 Correct 0 ms 6320 KB Output is correct
10 Correct 0 ms 6320 KB Output is correct
11 Correct 0 ms 6320 KB Output is correct
12 Correct 0 ms 6320 KB Output is correct
13 Correct 0 ms 6320 KB Output is correct
14 Correct 0 ms 6320 KB Output is correct
15 Correct 19 ms 6320 KB Output is correct
16 Correct 19 ms 6320 KB Output is correct
17 Correct 3 ms 6320 KB Output is correct
18 Correct 0 ms 6320 KB Output is correct
19 Correct 19 ms 6320 KB Output is correct
20 Correct 23 ms 6320 KB Output is correct
21 Correct 26 ms 6320 KB Output is correct
22 Correct 26 ms 6320 KB Output is correct
23 Correct 286 ms 6320 KB Output is correct
24 Correct 299 ms 6320 KB Output is correct
25 Correct 313 ms 6320 KB Output is correct
26 Correct 286 ms 6320 KB Output is correct
27 Correct 276 ms 6320 KB Output is correct
28 Correct 266 ms 6320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 196 ms 6320 KB Output is correct
2 Correct 209 ms 6320 KB Output is correct
3 Runtime error 0 ms 6320 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 6320 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -