Submission #973367

# Submission time Handle Problem Language Result Execution time Memory
973367 2024-05-01T20:42:07 Z AtabayRajabli Sure Bet (CEOI17_sure) C++17
100 / 100
108 ms 7084 KB
#include <bits/stdc++.h>
#define int ll
#define all(v) v.begin(), v.end()

// author : a1abay

using namespace std;

typedef long long ll;
typedef long double ld;
const int sz = 1e5 + 5;
const int inf = 1e9 + 7;

int n;
ld a[sz], b[sz];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    cin >> n;
    priority_queue<ld> qa, qb;
    ld l = 0, r = 0;
    for(int i = 1; i <= n; i++) 
    {
        cin >> a[i] >> b[i];
        qa.push(a[i]);
        qb.push(b[i]);
    }
    ld x = 0, ans = 0;
    while(!qa.empty() || !qb.empty())
    {
        if(l <= r && !qa.empty())
        {
            l += qa.top();
            qa.pop();
            x++;
        }
        else if(r <= l && !qb.empty())
        {
            r += qb.top();
            qb.pop();
            x++;
        }
        else 
        {
            break;
        }
        ans = max(ans, min(l - x, r - x));
    }
    cout << fixed << setprecision(4) << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2436 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2436 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 103 ms 6836 KB Output is correct
18 Correct 89 ms 6896 KB Output is correct
19 Correct 88 ms 6772 KB Output is correct
20 Correct 84 ms 7084 KB Output is correct
21 Correct 92 ms 6832 KB Output is correct
22 Correct 90 ms 6840 KB Output is correct
23 Correct 89 ms 6836 KB Output is correct
24 Correct 88 ms 6836 KB Output is correct
25 Correct 82 ms 6840 KB Output is correct
26 Correct 108 ms 6776 KB Output is correct