답안 #694054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
694054 2023-02-03T16:17:43 Z Elephant52 Sure Bet (CEOI17_sure) C++17
100 / 100
74 ms 3544 KB
#include<bits/stdc++.h>
 
using namespace std;
  
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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 0 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 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 2 ms 328 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 0 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 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 2 ms 328 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 67 ms 3148 KB Output is correct
18 Correct 65 ms 3152 KB Output is correct
19 Correct 67 ms 3148 KB Output is correct
20 Correct 66 ms 3288 KB Output is correct
21 Correct 74 ms 3544 KB Output is correct
22 Correct 66 ms 3260 KB Output is correct
23 Correct 66 ms 3152 KB Output is correct
24 Correct 66 ms 3260 KB Output is correct
25 Correct 66 ms 3148 KB Output is correct
26 Correct 73 ms 3532 KB Output is correct