Submission #155566

# Submission time Handle Problem Language Result Execution time Memory
155566 2019-09-29T06:46:09 Z keta_tsimakuridze Sure Bet (CEOI17_sure) C++14
100 / 100
225 ms 3616 KB
#include<bits/stdc++.h>
using namespace std;
int n,k,j;
double a[100005],b[100005],sum1,s1,sum2,ans;
 int main(){
	cin>>n;
	for(k=1;k<=n;k++){
		cin>>a[k]>>b[k];
		
		
	}
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	j=n;
	for(k=n;k>=1;k--){
		sum1+=a[k]-1;
		sum2--;
		while(sum2<sum1 && j>=1){
		sum1-=1;	sum2+=b[j]-1;
			ans=max(ans,min(sum1,sum2));
			
			j--;
		}
		
		
	} sum1=sum2=s1=0; j=n;
		for(k=n;k>=1;k--){
		sum1+=b[k]-1;
		sum2--; //cout<<sum2<<" "<<endl;
		while(sum2<sum1 && j>=1){
		sum1-=1;	sum2+=a[j]-1;
			ans=max(ans,min(sum1,sum2));
		
			j--;
		}
		
		
	}
	 printf("%.4lf",(double)ans);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 4 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 4 ms 376 KB Output is correct
17 Correct 193 ms 3212 KB Output is correct
18 Correct 205 ms 3280 KB Output is correct
19 Correct 192 ms 3292 KB Output is correct
20 Correct 193 ms 3404 KB Output is correct
21 Correct 225 ms 3584 KB Output is correct
22 Correct 196 ms 3320 KB Output is correct
23 Correct 191 ms 3292 KB Output is correct
24 Correct 192 ms 3320 KB Output is correct
25 Correct 193 ms 3176 KB Output is correct
26 Correct 224 ms 3616 KB Output is correct