Submission #118505

# Submission time Handle Problem Language Result Execution time Memory
118505 2019-06-19T06:18:32 Z zubec Sure Bet (CEOI17_sure) C++14
100 / 100
245 ms 11536 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int n;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);

    cin >> n;
    multiset<double> q1, q2;
    for (int i = 1; i <= n; i++){
        double a, b;
        cin >> a >> b;
        q1.insert(a);
        q2.insert(b);
    }
    ld mx = 0;
    ld sum1 = 0, sum2 = 0;
    while(1){
        if (q1.empty() && q2.empty())
            break;
        if (sum1 < sum2){
            if (q1.empty())
                break;
            double num = *prev(q1.end());
            q1.erase(prev(q1.end()));
            sum1 += num-1;
            --sum2;
        } else {
            if (q2.empty())
                break;
            double num = *prev(q2.end());
            q2.erase(prev(q2.end()));
            sum2 += num-1;
            --sum1;
        }
        mx = max(mx, min(sum1, sum2));
    }
    cout.precision(4);
    cout << fixed << mx;

}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 512 KB Output is correct
13 Correct 3 ms 512 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 512 KB Output is correct
13 Correct 3 ms 512 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 219 ms 11072 KB Output is correct
18 Correct 229 ms 11044 KB Output is correct
19 Correct 228 ms 11128 KB Output is correct
20 Correct 226 ms 11128 KB Output is correct
21 Correct 231 ms 11536 KB Output is correct
22 Correct 245 ms 11124 KB Output is correct
23 Correct 237 ms 11164 KB Output is correct
24 Correct 222 ms 11100 KB Output is correct
25 Correct 218 ms 11140 KB Output is correct
26 Correct 223 ms 11512 KB Output is correct