Submission #693408

# Submission time Handle Problem Language Result Execution time Memory
693408 2023-02-03T02:34:36 Z TriangleBicycle Sure Bet (CEOI17_sure) C++17
100 / 100
76 ms 3624 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using graph = vector<vector<int>>;


int main() {
	ios::sync_with_stdio(false), cin.tie(nullptr);
	int N;
	cin >> N;

	vector<double> a(N), b(N);
	for(int i = 0; i < N; ++i)
		cin >> a[i] >> b[i];

	sort(a.begin(), a.end(), greater<>());
	sort(b.begin(), b.end(), greater<>());

	double ans = 0;
	int bets_taken = 0;

	int ap = 0, bp = 0;
	double a_sum = 0, b_sum = 0;

	for (int i = 0; i < 2 * N; ++i) {
		if (ap < N && bp < N) {
			if (a_sum < b_sum) {
				a_sum += a[ap++];
			} else {
				b_sum += b[bp++];
			}
		} else if (ap < N) {
			a_sum += a[ap++];
		} else if (bp < N) {
			b_sum += b[bp++];
		} else {
			assert(0);
		}

		++bets_taken;
		ans = max(ans, min(a_sum, b_sum) - bets_taken);
	}
	cout << fixed << setprecision(4) << ans << endl;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 236 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 236 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 236 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 67 ms 3152 KB Output is correct
18 Correct 71 ms 3264 KB Output is correct
19 Correct 66 ms 3264 KB Output is correct
20 Correct 73 ms 3380 KB Output is correct
21 Correct 75 ms 3532 KB Output is correct
22 Correct 70 ms 3260 KB Output is correct
23 Correct 69 ms 3160 KB Output is correct
24 Correct 76 ms 3144 KB Output is correct
25 Correct 67 ms 3256 KB Output is correct
26 Correct 76 ms 3624 KB Output is correct