답안 #380970

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
380970 2021-03-23T21:25:06 Z wind_reaper Sure Bet (CEOI17_sure) C++17
100 / 100
103 ms 3820 KB
#include <bits/stdc++.h>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
	
	int n;
	cin >> n;

	vector<double> a(n+1), b(n+1);
	for(int i = 1; i <= n; i++){
		cin >> a[i] >> b[i];
	}

	sort(a.rbegin(), a.rend() - 1);
	sort(b.rbegin(), b.rend() - 1);

	double sa = 0, sb = 0, ans = 0;
	int ia = 1, ib = 1;
	for(int i = 1; i <= 2*n; i++){
		if(ia == n+1)
			sb += b[ib++];
		else if(ib == n+1)
			sa += a[ia++];
		else{
			if(sa > sb)
				sb += b[ib++];
			else sa += a[ia++];
		}
		ans = max(ans, min(sa, sb) - i);
	}

	cout << fixed << setprecision(4) << ans << '\n';
	return 0; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
17 Correct 87 ms 3308 KB Output is correct
18 Correct 84 ms 3228 KB Output is correct
19 Correct 84 ms 3228 KB Output is correct
20 Correct 83 ms 3308 KB Output is correct
21 Correct 90 ms 3692 KB Output is correct
22 Correct 88 ms 3308 KB Output is correct
23 Correct 85 ms 3308 KB Output is correct
24 Correct 103 ms 3308 KB Output is correct
25 Correct 91 ms 3308 KB Output is correct
26 Correct 94 ms 3820 KB Output is correct