Submission #891170

# Submission time Handle Problem Language Result Execution time Memory
891170 2023-12-22T09:43:27 Z vjudge1 Sure Bet (CEOI17_sure) C++17
100 / 100
89 ms 4724 KB
#include <bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define ll long long
#define ull unsigned long long
#define ld long double
#define pf push_front
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()

void boost(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	return;
}

void solve(){
	int n;
	cin>>n;
	ld a[n],b[n];
	for(int i=0; i<n; i++) cin>>a[i]>>b[i];
	sort(a,a+n,greater<double>());
	sort(b,b+n,greater<double>());
	int p1=0,p2=0;
	int cnt=0;
	ld suma=0,sumb=0;
	ld ans=0;
	while(p1<n||p2<n){
		if(p1==n||p2==n){
			if(p1==n){
				sumb+=b[p2];
				p2++;
			}
			else{
				suma+=a[p1];
				p1++;
			}
		}
		else{
			if(suma>sumb){
				sumb+=b[p2];
				p2++;
			}
			else{
				suma+=a[p1];
				p1++;
			}
		}
		cnt++;
		ans=max(ans,min(suma,sumb)-cnt);
	}
	cout<<fixed<<setprecision(4)<<ans;
	return;
}

int main(){
	boost();
	solve();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 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 1 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 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 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 460 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 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 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 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 460 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 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 74 ms 4436 KB Output is correct
18 Correct 72 ms 4444 KB Output is correct
19 Correct 72 ms 4596 KB Output is correct
20 Correct 73 ms 4444 KB Output is correct
21 Correct 77 ms 4440 KB Output is correct
22 Correct 77 ms 4724 KB Output is correct
23 Correct 72 ms 4436 KB Output is correct
24 Correct 85 ms 4592 KB Output is correct
25 Correct 72 ms 4596 KB Output is correct
26 Correct 89 ms 4688 KB Output is correct