Submission #52697

# Submission time Handle Problem Language Result Execution time Memory
52697 2018-06-26T11:27:54 Z snat123 Sure Bet (CEOI17_sure) C++14
100 / 100
207 ms 3764 KB
#include<bits/stdc++.h>
 
using namespace std;
 
long double a[100001], b[100001];
 
int main(){
    int n;
    cin >> n;
    for(int i=0; i<n; i++) cin >> a[i] >> b[i];
    sort(a, a+n);
	sort(b, b+n);
	int i=n-1, j=n-1;
	long double x=0.0, y=0.0, res=0.0;
	while(i>=0 || j>=0){
		if((i<0 || x>y) && j>=0) y+=b[j--];
		else if(i>=0 )x+=a[i--];
		else break;
		res=max(res, min(x, y)-(n-i)-(n-j)+2);
	}
	cout << fixed << setprecision(4) << res;
    return 0;
} 
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 544 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 544 KB Output is correct
9 Correct 2 ms 544 KB Output is correct
10 Correct 2 ms 600 KB Output is correct
11 Correct 2 ms 620 KB Output is correct
12 Correct 3 ms 620 KB Output is correct
13 Correct 3 ms 620 KB Output is correct
14 Correct 3 ms 620 KB Output is correct
15 Correct 3 ms 676 KB Output is correct
16 Correct 4 ms 676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 544 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 544 KB Output is correct
9 Correct 2 ms 544 KB Output is correct
10 Correct 2 ms 600 KB Output is correct
11 Correct 2 ms 620 KB Output is correct
12 Correct 3 ms 620 KB Output is correct
13 Correct 3 ms 620 KB Output is correct
14 Correct 3 ms 620 KB Output is correct
15 Correct 3 ms 676 KB Output is correct
16 Correct 4 ms 676 KB Output is correct
17 Correct 166 ms 3664 KB Output is correct
18 Correct 172 ms 3664 KB Output is correct
19 Correct 173 ms 3664 KB Output is correct
20 Correct 171 ms 3664 KB Output is correct
21 Correct 193 ms 3708 KB Output is correct
22 Correct 168 ms 3764 KB Output is correct
23 Correct 168 ms 3764 KB Output is correct
24 Correct 169 ms 3764 KB Output is correct
25 Correct 192 ms 3764 KB Output is correct
26 Correct 207 ms 3764 KB Output is correct