Submission #585386

# Submission time Handle Problem Language Result Execution time Memory
585386 2022-06-28T19:05:22 Z tengiz05 Sure Bet (CEOI17_sure) C++17
100 / 100
84 ms 5196 KB
#include <bits/stdc++.h>

using i64 = long long;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    
    vector<double> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    
    sort(a.begin(), a.end(), greater());
    sort(b.begin(), b.end(), greater());
    
    vector<double> pa(n + 1), pb(n + 1);
    
    for (int i = 0; i < n; i++) {
        pa[i + 1] = pa[i] + a[i];
        pb[i + 1] = pb[i] + b[i];
    }
    
    double ans = 0;
    
    for (int i = 1, j = 0; i <= n; i++) {
        while (j < n && pb[j] < pa[i]) {
            j++;
        }
        ans = max(ans, min(pa[i], pb[j]) - i - j);
    }
    
    for (int i = 1, j = 0; i <= n; i++) {
        while (j < n && pa[j] < pb[i]) {
            j++;
        }
        ans = max(ans, min(pa[j], pb[i]) - i - j);
    }
    
    cout << fixed << setprecision(4);
    cout << ans << "\n";
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
17 Correct 70 ms 4692 KB Output is correct
18 Correct 72 ms 4692 KB Output is correct
19 Correct 68 ms 4812 KB Output is correct
20 Correct 68 ms 4696 KB Output is correct
21 Correct 78 ms 5196 KB Output is correct
22 Correct 71 ms 4804 KB Output is correct
23 Correct 84 ms 4808 KB Output is correct
24 Correct 70 ms 4792 KB Output is correct
25 Correct 69 ms 4816 KB Output is correct
26 Correct 74 ms 5156 KB Output is correct