Submission #886741

# Submission time Handle Problem Language Result Execution time Memory
886741 2023-12-12T18:22:50 Z aykhn Sure Bet (CEOI17_sure) C++17
100 / 100
106 ms 3668 KB
#include <bits/stdc++.h>
 
// author : aykhn
 
using namespace std;
typedef long long ll;
 
#define pb push_back
#define ins insert
#define mpr make_pair
#define all(v) v.begin(), v.end()
#define bpc __builtin_popcount
#define bpcll __builtin_popcountll
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define infll 0x3F3F3F3F3F3F3F3F
#define inf 0x3F3F3F3F
 
void _()
{
    int n;
    cin >> n;
    double a[n], b[n];
    double res = 0;
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    sort(a, a + n, greater<double> ());
    sort(b, b + n, greater<double> ());
    int i = 0;
    int j = 0;
    double sum1 = 0, sum2 = 0;
    while (i < n || j < n)
    {
        if (i == n) sum2 += b[j++];
        else if (j == n) sum1 += a[i++];
        else if (sum1 + a[i] <= sum2 + b[j]) sum1 += a[i++];
        else sum2 += b[j++];
        res = max(res, min(sum2, sum1) - i - j);
    }
  	cout.precision(4);
    cout << fixed << res << '\n';
}
 
signed main()
{
    int t = 1;
    // cin >> t;
    for (int tt = 0; tt < t; tt++)
    {
        _();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 444 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 444 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 92 ms 3104 KB Output is correct
18 Correct 94 ms 3152 KB Output is correct
19 Correct 93 ms 3236 KB Output is correct
20 Correct 94 ms 3240 KB Output is correct
21 Correct 105 ms 3668 KB Output is correct
22 Correct 92 ms 3152 KB Output is correct
23 Correct 93 ms 3112 KB Output is correct
24 Correct 94 ms 3152 KB Output is correct
25 Correct 102 ms 3412 KB Output is correct
26 Correct 106 ms 3668 KB Output is correct