Submission #865426

# Submission time Handle Problem Language Result Execution time Memory
865426 2023-10-24T08:13:03 Z vjudge1 Sure Bet (CEOI17_sure) C++17
100 / 100
70 ms 11936 KB
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef long double ld;

#define all(x) x.begin(),x.end()
#define pb push_back
#define ent "\n"

const int maxn = (int)3e5 + 13;
const ll inf = (long long)1e18 + 20;
const int mod = (int)1e9 + 7;

int n;
ld a[maxn],b[maxn];
ld pref[maxn];
ld suf[maxn];

int get(int x,int y){
	int ans = x / pow(4,y);
	ans %= 4;
	return ans;
}

void solve(){
	cin >> n;
	for(int i = 1 ; i <= n ; i ++){
		cin >> a[i] >> b[i];
	}
	sort(a + 1,a + n + 1);
	sort(b + 1,b + n + 1);
	for(int i = 1 ; i <= n ; i ++){
		pref[i] = pref[i - 1] + b[i];
	}
	ld mx =0 ,sum = 0,sum1 = 0;
	int ind = n;
	for(int i = n ; i >= 1 ; i --){
		sum += a[i];
		sum1 = 0;
		for(int j = ind ; j >= 1 ; j --){
			sum1 = pref[n] - pref[j - 1];
			int kol = (n - i + 1) + (n - j + 1);
			mx = max(mx,min(sum1,sum) - kol);
			if(sum1 > sum){
				ind = j;
				break;
			}
		}
	}
	printf("%.4lf",(double)mx);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	while(t --){
		solve();
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4440 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4440 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 64 ms 10196 KB Output is correct
18 Correct 65 ms 11600 KB Output is correct
19 Correct 66 ms 11592 KB Output is correct
20 Correct 65 ms 11460 KB Output is correct
21 Correct 69 ms 11936 KB Output is correct
22 Correct 65 ms 11348 KB Output is correct
23 Correct 65 ms 11564 KB Output is correct
24 Correct 66 ms 11344 KB Output is correct
25 Correct 65 ms 11556 KB Output is correct
26 Correct 70 ms 11932 KB Output is correct