Submission #504129

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

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

    vector <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);

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

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

    double ans = max(0.0, 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 -