Submission #52694

# Submission time Handle Problem Language Result Execution time Memory
52694 2018-06-26T11:23:35 Z snat123 Sure Bet (CEOI17_sure) C++14
100 / 100
178 ms 16776 KB
#include<bits/stdc++.h>
 
using namespace std;
 
double a[100001], b[100001];
 
int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	//ifstream cin;
	//ofstream cout;
	//cin.open("input.txt");
	//cout.open("output.txt");
    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, li=-1, lj=-1;
	double x=0.0, y=0.0, res=0.0;
	while(i>=0 || j>=0){
		if(j>=0 && x>y) y+=b[j--];
		else if(i>=0 )x+=a[i--];
		else break;
		res=max(res, min(x, y)-(n-i)-(n-j)+2);
		//cout << i << " " << j << endl;
	}
	cout << fixed << setprecision(4) << res;
	//cin.close();
	//cout.close();
    return 0;
} 

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:19:20: warning: unused variable 'li' [-Wunused-variable]
  int i=n-1, j=n-1, li=-1, lj=-1;
                    ^~
sure.cpp:19:27: warning: unused variable 'lj' [-Wunused-variable]
  int i=n-1, j=n-1, li=-1, lj=-1;
                           ^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 2 ms 560 KB Output is correct
8 Correct 2 ms 560 KB Output is correct
9 Correct 2 ms 688 KB Output is correct
10 Correct 2 ms 688 KB Output is correct
11 Correct 2 ms 688 KB Output is correct
12 Correct 3 ms 688 KB Output is correct
13 Correct 3 ms 688 KB Output is correct
14 Correct 4 ms 784 KB Output is correct
15 Correct 4 ms 784 KB Output is correct
16 Correct 4 ms 784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 560 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 2 ms 560 KB Output is correct
8 Correct 2 ms 560 KB Output is correct
9 Correct 2 ms 688 KB Output is correct
10 Correct 2 ms 688 KB Output is correct
11 Correct 2 ms 688 KB Output is correct
12 Correct 3 ms 688 KB Output is correct
13 Correct 3 ms 688 KB Output is correct
14 Correct 4 ms 784 KB Output is correct
15 Correct 4 ms 784 KB Output is correct
16 Correct 4 ms 784 KB Output is correct
17 Correct 153 ms 3588 KB Output is correct
18 Correct 153 ms 4952 KB Output is correct
19 Correct 153 ms 6416 KB Output is correct
20 Correct 154 ms 7760 KB Output is correct
21 Correct 177 ms 9544 KB Output is correct
22 Correct 154 ms 10984 KB Output is correct
23 Correct 163 ms 12432 KB Output is correct
24 Correct 154 ms 13572 KB Output is correct
25 Correct 153 ms 14992 KB Output is correct
26 Correct 178 ms 16776 KB Output is correct