Submission #504131

# Submission time Handle Problem Language Result Execution time Memory
504131 2022-01-09T22:06:54 Z sophiadamm Sure Bet (CEOI17_sure) C++17
0 / 100
0 ms 204 KB
#include <bits/stdc++.h>
using namespace std;

bool ord(long double a, long double b){
    return a > b;
}
int main(){
    int n; cin >> n;

    vector <long double> f(n), s(n);

    for(int i = 0; i<n; i++) cin >> f[i] >> s[i];

    sort(f.begin(), f.end(), ord);
    sort(s.begin(), s.end(), ord);

    long double ans = 0, i = 0, j = 0, si = 0, sj = 0;

    if(f[i] > s[i]){
      i = 1;
      si += f[0];
    }else{
      j = 1;
      sj += s[0];
    }

    ans = max(ans, min(sj, si) - (i+j));

    while(i < n && j < n){

        if(sj < si){
            sj += s[j];
            j++;
        }else{
            si += f[i];
            i++;
        }

        ans = max(ans, min(sj, si) - (i+j));
    }

    cout.precision(4);
    cout.setf(ios::fixed);

    cout << ans << endl;



}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -