Submission #79339

# Submission time Handle Problem Language Result Execution time Memory
79339 2018-10-12T10:08:44 Z Saboon Sure Bet (CEOI17_sure) C++14
100 / 100
129 ms 3820 KB
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <iomanip>
#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int maxn = 1e5 + 10;
const int maxm = 1e5 + 10;
const int mod = 1e9 + 7;

ld p[maxn], q[maxn];

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> p[i] >> q[i];

	sort (p + 1, p + n + 1, greater <ld> ());
	sort (q + 1, q + n + 1, greater <ld> ());

	ld ans = 0, fi = 0, se = 0;
	int idxse = 0;
	for (int idxfi = 1; idxfi <= n; idxfi ++) {
		fi += p[idxfi] - 1;
		se --;
		ans = max (ans, min (fi, se));
//		cout << idxfi << " " << idxse << " -> " << fi << " " << se << endl;
		while (se < fi and idxse < n) {
			idxse ++;
			se += q[idxse] - 1;
			fi --;
//			cout << idxfi << " " << idxse << " -> " << fi << " " << se << endl;
			ans = max (ans, min (fi, se));
		}
	}
	cout << fixed << setprecision (4) << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 524 KB Output is correct
8 Correct 2 ms 652 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 2 ms 652 KB Output is correct
11 Correct 2 ms 652 KB Output is correct
12 Correct 3 ms 652 KB Output is correct
13 Correct 3 ms 652 KB Output is correct
14 Correct 3 ms 652 KB Output is correct
15 Correct 3 ms 652 KB Output is correct
16 Correct 3 ms 652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 524 KB Output is correct
8 Correct 2 ms 652 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 2 ms 652 KB Output is correct
11 Correct 2 ms 652 KB Output is correct
12 Correct 3 ms 652 KB Output is correct
13 Correct 3 ms 652 KB Output is correct
14 Correct 3 ms 652 KB Output is correct
15 Correct 3 ms 652 KB Output is correct
16 Correct 3 ms 652 KB Output is correct
17 Correct 112 ms 3612 KB Output is correct
18 Correct 114 ms 3784 KB Output is correct
19 Correct 115 ms 3792 KB Output is correct
20 Correct 113 ms 3792 KB Output is correct
21 Correct 129 ms 3792 KB Output is correct
22 Correct 115 ms 3792 KB Output is correct
23 Correct 114 ms 3792 KB Output is correct
24 Correct 119 ms 3792 KB Output is correct
25 Correct 114 ms 3792 KB Output is correct
26 Correct 125 ms 3820 KB Output is correct