Submission #155583

# Submission time Handle Problem Language Result Execution time Memory
155583 2019-09-29T07:21:18 Z lukameladze Sure Bet (CEOI17_sure) C++14
100 / 100
224 ms 2044 KB
#include <bits/stdc++.h>
using namespace std;
double a[100005],b[100005],k,l,r,k1,ans,sum1,sum2;
int n,fs,j;
int main()
{
	cin>>n;
	for (int i=1; i<=n; i++)
	{
		cin>>a[i]>>b[i];
	}
	sort(a+1, a+n+1);
	sort(b+1, b+n+1);
	j=n;
	for (int i=n; i>=1; i--)
	{
		sum1+=a[i]-1;
		sum2--;
		while (sum2<sum1)
		{
			if (j<1) break;
			sum1--;
			sum2+=b[j]-1;
			ans=max(ans,min(sum1,sum2));
			j--;
		}
	}
	sum1=0;
	sum2=0;
	j=n;
	for (int i=n; i>=1; i--)
	{
		sum2+=b[i]-1;
		sum1--;
		while (sum1<sum2)
		{
			if (j<1) break;
			sum2--;
			sum1+=a[j]-1;
			ans=max(ans,min(sum1,sum2));
			j--;
		}
	}
	
	 printf("%.4lf",(double)ans);



}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 252 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 252 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 380 KB Output is correct
16 Correct 4 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 252 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 380 KB Output is correct
16 Correct 4 ms 376 KB Output is correct
17 Correct 189 ms 1832 KB Output is correct
18 Correct 192 ms 2004 KB Output is correct
19 Correct 191 ms 2040 KB Output is correct
20 Correct 208 ms 2044 KB Output is correct
21 Correct 222 ms 1868 KB Output is correct
22 Correct 190 ms 1788 KB Output is correct
23 Correct 190 ms 2036 KB Output is correct
24 Correct 191 ms 2040 KB Output is correct
25 Correct 191 ms 1880 KB Output is correct
26 Correct 224 ms 1816 KB Output is correct