Submission #865757

# Submission time Handle Problem Language Result Execution time Memory
865757 2023-10-24T15:14:41 Z vjudge1 Sure Bet (CEOI17_sure) C++17
100 / 100
70 ms 5192 KB
//gm  --- akezhon
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define int long long
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define tm (tl+tr)/2
#define TL v+v, tl, tm
#define TR v+v+1, tm+1, tr
#define DA l <= tl && tr <= r
#define NET r < tl || tr < l
#define double long double
using namespace std;
const int N=1e5+7;
const int M=1e9+7;
const int inf=1e9;
double a[N], b[N];
int n;
void AlemAmenov(){
	
	cin >> n;
	for(int i=1; i <= n; i++){
		cin >> a[i] >> b[i];
	}
	sort(a+1, a+1+n);
	sort(b+1, b+1+n);
	reverse(a+1, a+1+n);
	reverse(b+1, b+1+n);
	
	double ans=0, aa=0, bb=0;
	int j=0;
	for(int i=1; i <= n; i++){
		aa += a[i];
		ans = max(ans, min(aa, bb)-i-j);
		while(bb < aa && j < n){
			bb += b[++j];
			ans = max(ans, min(aa, bb)-i-j);
		}
		ans = max(ans, min(aa, bb)-i-j);
	}
	cout << fixed << setprecision(4) << ans;
}
signed main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	// freopen("promote.in", "r", stdin);
	// freopen("promote.out", "w", stdout);
	int RealName=1;
	// cin >> RealName;
	// int C=0;
	while(RealName--){
		// cout << "Case " << ++C << ":\n";
		AlemAmenov();
	}

return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2528 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2528 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 67 ms 3484 KB Output is correct
18 Correct 70 ms 3408 KB Output is correct
19 Correct 66 ms 3528 KB Output is correct
20 Correct 65 ms 3468 KB Output is correct
21 Correct 68 ms 3472 KB Output is correct
22 Correct 65 ms 4816 KB Output is correct
23 Correct 65 ms 5192 KB Output is correct
24 Correct 66 ms 4732 KB Output is correct
25 Correct 65 ms 4948 KB Output is correct
26 Correct 69 ms 5116 KB Output is correct