Submission #40042

# Submission time Handle Problem Language Result Execution time Memory
40042 2018-01-25T18:30:33 Z igzi Sure Bet (CEOI17_sure) C++14
100 / 100
182 ms 3580 KB
#include <bits/stdc++.h>
#define maxN 100001

using namespace std;
double m=0,a[maxN],b[maxN],x,y;
bool poredi(float a,float b){
    return a>b;
}

int main() {
    long long n,i,j;
    x=y=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    sort(a,a+n,poredi);
    sort(b,b+n,poredi);
    i=j=0;
    while(i<n){
        x+=a[i];
        i++;
        while(j<n && y<x){
            if(m<min(x,y)-i-j) m=min(x,y)-i-j;
            y+=b[j];
            j++;
        }
        if(m<min(x,y)-i-j) m=min(x,y)-i-j;
    }
    cout<<fixed<<setprecision(4)<<m<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3580 KB Output is correct
2 Correct 0 ms 3580 KB Output is correct
3 Correct 0 ms 3580 KB Output is correct
4 Correct 0 ms 3580 KB Output is correct
5 Correct 0 ms 3580 KB Output is correct
6 Correct 0 ms 3580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3580 KB Output is correct
2 Correct 0 ms 3580 KB Output is correct
3 Correct 0 ms 3580 KB Output is correct
4 Correct 0 ms 3580 KB Output is correct
5 Correct 0 ms 3580 KB Output is correct
6 Correct 0 ms 3580 KB Output is correct
7 Correct 0 ms 3580 KB Output is correct
8 Correct 1 ms 3580 KB Output is correct
9 Correct 0 ms 3580 KB Output is correct
10 Correct 0 ms 3580 KB Output is correct
11 Correct 0 ms 3580 KB Output is correct
12 Correct 2 ms 3580 KB Output is correct
13 Correct 0 ms 3580 KB Output is correct
14 Correct 3 ms 3580 KB Output is correct
15 Correct 2 ms 3580 KB Output is correct
16 Correct 2 ms 3580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3580 KB Output is correct
2 Correct 0 ms 3580 KB Output is correct
3 Correct 0 ms 3580 KB Output is correct
4 Correct 0 ms 3580 KB Output is correct
5 Correct 0 ms 3580 KB Output is correct
6 Correct 0 ms 3580 KB Output is correct
7 Correct 0 ms 3580 KB Output is correct
8 Correct 1 ms 3580 KB Output is correct
9 Correct 0 ms 3580 KB Output is correct
10 Correct 0 ms 3580 KB Output is correct
11 Correct 0 ms 3580 KB Output is correct
12 Correct 2 ms 3580 KB Output is correct
13 Correct 0 ms 3580 KB Output is correct
14 Correct 3 ms 3580 KB Output is correct
15 Correct 2 ms 3580 KB Output is correct
16 Correct 2 ms 3580 KB Output is correct
17 Correct 154 ms 3580 KB Output is correct
18 Correct 179 ms 3580 KB Output is correct
19 Correct 166 ms 3580 KB Output is correct
20 Correct 168 ms 3580 KB Output is correct
21 Correct 176 ms 3580 KB Output is correct
22 Correct 156 ms 3580 KB Output is correct
23 Correct 156 ms 3580 KB Output is correct
24 Correct 160 ms 3580 KB Output is correct
25 Correct 162 ms 3580 KB Output is correct
26 Correct 182 ms 3580 KB Output is correct