Submission #970876

# Submission time Handle Problem Language Result Execution time Memory
970876 2024-04-27T12:36:00 Z efedmrlr Sure Bet (CEOI17_sure) C++17
100 / 100
74 ms 5212 KB
// #pragma GCC optimize("O3,Ofast,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>

using namespace std;

#define ld long double
#define lli long long int
#define MP make_pair
#define pb push_back
#define REP(i,n) for(int i = 0; (i) < (n); (i)++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()


void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}


const double EPS = 0.00001;
const int INF = 1e9+500;
const int N = 3e5+5;
const int ALPH = 26;
const int LGN = 25;
constexpr int MOD = 1e9+7;
int n,m,q;
vector<ld> a, b;
inline void solve() {
    cin>>n;
    ld ans = 0;
    a.resize(n);
    b.resize(n);
    REP(i, n) {
        cin >> a[i] >> b[i];
    }
    sort(rall(a));
    sort(rall(b));
    int i = 0, j = 0;
    ld cura = 0, curb = 0;
    while(i < n || j < n) {
        if(cura < curb) {
            if(i >= n) break;
            cura += a[i];
            i++;
        }
        else { 
            if(j >= n) break;
            curb += b[j];
            j++;
        }
        ans = max(ans, min(cura, curb) - (i + j));

    }
    cout << fixed << setprecision(4) << ans << "\n";
}
 
signed main() {

    fastio();
    int test = 1;
    //cin>>test;
    while(test--) {
        solve();
    }
    
}
# 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 0 ms 348 KB Output is correct
4 Correct 0 ms 456 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 0 ms 348 KB Output is correct
4 Correct 0 ms 456 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 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 512 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 0 ms 348 KB Output is correct
4 Correct 0 ms 456 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 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 67 ms 4856 KB Output is correct
18 Correct 67 ms 4948 KB Output is correct
19 Correct 67 ms 4956 KB Output is correct
20 Correct 67 ms 4948 KB Output is correct
21 Correct 74 ms 5212 KB Output is correct
22 Correct 68 ms 4944 KB Output is correct
23 Correct 67 ms 4956 KB Output is correct
24 Correct 67 ms 4948 KB Output is correct
25 Correct 68 ms 4744 KB Output is correct
26 Correct 71 ms 5204 KB Output is correct