Submission #1088514

# Submission time Handle Problem Language Result Execution time Memory
1088514 2024-09-14T14:33:08 Z 4QT0R Sure Bet (CEOI17_sure) C++17
100 / 100
63 ms 3764 KB
#include <bits/stdc++.h>
using namespace std;

vector<double> a;
vector<double> b;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;
	a.resize(n);
	b.resize(n);
	for (int i = 0; i<n; i++)cin >> a[i] >> b[i];
	sort(a.begin(),a.end(),greater<double>());
	sort(b.begin(),b.end(),greater<double>());
	int x=0,y=0;
	double ans=0,sma=0,smb=0;
	while(min(x,y)<n){
		if (x<n && (sma<smb || y==n))sma+=a[x++];
		else smb+=b[y++];
		ans=max(ans,min(sma,smb)-(x+y));
	}
	cout << fixed << setprecision(4) << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 372 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 372 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 456 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 372 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 456 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 488 KB Output is correct
17 Correct 48 ms 3332 KB Output is correct
18 Correct 51 ms 3316 KB Output is correct
19 Correct 49 ms 3164 KB Output is correct
20 Correct 48 ms 3164 KB Output is correct
21 Correct 62 ms 3756 KB Output is correct
22 Correct 52 ms 3388 KB Output is correct
23 Correct 48 ms 3296 KB Output is correct
24 Correct 48 ms 3300 KB Output is correct
25 Correct 49 ms 3384 KB Output is correct
26 Correct 63 ms 3764 KB Output is correct