Submission #161550

# Submission time Handle Problem Language Result Execution time Memory
161550 2019-11-03T05:55:34 Z amoo_safar Sure Bet (CEOI17_sure) C++14
100 / 100
148 ms 3832 KB
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef string str;

const ll Mod = 1e9 + 7;
const int Maxn = 2e5 + 100;

double a[Maxn], b[Maxn], ans;
int n;

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
	sort(a, a + n);
	sort(b, b + n);
	reverse(a, a + n);
	reverse(b, b + n);
	
	b[n] = 1e9;
	int p = 0;
	double c = 0, s1 = 0, s2 = 0;
	
	for(int i = 0; i < n; i++){
		s1 += a[i]; c++;
		ans = max(ans, min(s1, s2) - c);
		while(s2 < s1 && p < n){
			s2 += b[p ++]; c += 1;
			ans = max(ans, min(s1, s2) - c);
		}
	}
	cout << fixed << setprecision(4) << ans << '\n';
	return 0;
}
/*
4
1.4 3.7
1.2 2
1.6 1.4
1.9 1.5
*/
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 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 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 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 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 148 ms 3360 KB Output is correct
18 Correct 99 ms 3344 KB Output is correct
19 Correct 119 ms 3372 KB Output is correct
20 Correct 98 ms 3352 KB Output is correct
21 Correct 107 ms 3832 KB Output is correct
22 Correct 98 ms 3360 KB Output is correct
23 Correct 97 ms 3448 KB Output is correct
24 Correct 113 ms 3320 KB Output is correct
25 Correct 101 ms 3320 KB Output is correct
26 Correct 106 ms 3704 KB Output is correct