Submission #51820

# Submission time Handle Problem Language Result Execution time Memory
51820 2018-06-21T09:27:49 Z istlemin Sure Bet (CEOI17_sure) C++14
100 / 100
124 ms 4376 KB
#include<bits/stdc++.h>

using namespace std;

#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;

ll n;
vector<double> a;
vector<double> b;
/*
double best = 0;

void getBest(ll index, double sumA, double sumB){
	if(index==n){
		best = max(best,min(sumA,sumB));
		return;
	}
	getBest(index+1,sumA+a[index]-2,sumB+b[index]-2);
	getBest(index+1,sumA+a[index]-1,sumB-1);
	getBest(index+1,sumA-1,sumB+b[index]-1);
	getBest(index+1,sumA,sumB);
}*/

int main(){
	cin.sync_with_stdio(false);
    cin>>n;
    a.resize(n);
    b.resize(n);
    rep(i,0,n) cin>>a[i]>>b[i];
    //getBest(0,0,0);

    sort(all(a));
    sort(all(b));
    reverse(all(a));
    reverse(all(b));

    vector<double> sumA(n+1);
    rep(i,0,n) sumA[i+1] = sumA[i] + a[i];
    vector<double> sumB(n+1);
    rep(i,0,n) sumB[i+1] = sumB[i] + b[i];

    double best = 0;

    rep(i,1,n+1){
        ll bi = lower_bound(all(sumB),sumA[i])-sumB.begin();
        rep(j,bi-1,bi+2){
			if(j<1||j>n) continue;
			best = max(best,min(sumA[i]-i-j,sumB[j]-i-j));
        }
    }



    printf("%.4lf",(double)best);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 488 KB Output is correct
7 Correct 3 ms 532 KB Output is correct
8 Correct 3 ms 716 KB Output is correct
9 Correct 2 ms 716 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
11 Correct 2 ms 716 KB Output is correct
12 Correct 3 ms 716 KB Output is correct
13 Correct 3 ms 716 KB Output is correct
14 Correct 3 ms 772 KB Output is correct
15 Correct 3 ms 772 KB Output is correct
16 Correct 3 ms 772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 488 KB Output is correct
7 Correct 3 ms 532 KB Output is correct
8 Correct 3 ms 716 KB Output is correct
9 Correct 2 ms 716 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
11 Correct 2 ms 716 KB Output is correct
12 Correct 3 ms 716 KB Output is correct
13 Correct 3 ms 716 KB Output is correct
14 Correct 3 ms 772 KB Output is correct
15 Correct 3 ms 772 KB Output is correct
16 Correct 3 ms 772 KB Output is correct
17 Correct 105 ms 4148 KB Output is correct
18 Correct 118 ms 4148 KB Output is correct
19 Correct 108 ms 4148 KB Output is correct
20 Correct 116 ms 4224 KB Output is correct
21 Correct 124 ms 4280 KB Output is correct
22 Correct 105 ms 4308 KB Output is correct
23 Correct 104 ms 4308 KB Output is correct
24 Correct 112 ms 4376 KB Output is correct
25 Correct 123 ms 4376 KB Output is correct
26 Correct 111 ms 4376 KB Output is correct