Submission #848904

# Submission time Handle Problem Language Result Execution time Memory
848904 2023-09-13T17:04:34 Z sandry24 Sure Bet (CEOI17_sure) C++17
60 / 100
2000 ms 1880 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
 
void solve(){
    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<double>());
    sort(b.begin(), b.end(), greater<double>());
    double total_a = 0, total_b = 0, total_max = 0;
    for(int i = 0; i < n; i++){
        total_a += a[i];
        total_b = 0;
        total_max = max(total_max, min(total_a, total_b - (i+1)));
        //cout << total_a << ' ' << -(i+1) << ' ' << i << '\n';
        for(int j = 0; j < n; j++){
            total_b += b[j];
            total_max = max(total_max, min(total_a - (j+i+2), total_b - (j+i+2)));
            //cout << total_a - (j+i+2) << ' ' << total_b - (j+i+2) <<  ' ' << '\n';
        }
    }
    cout << fixed << setprecision(4) << total_max << '\n';
}
 
int main(){
    //freopen("flota.in", "r", stdin);
    //freopen("flota.out", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 3 ms 344 KB Output is correct
13 Correct 3 ms 344 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 3 ms 344 KB Output is correct
13 Correct 3 ms 344 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Execution timed out 2043 ms 1880 KB Time limit exceeded
18 Halted 0 ms 0 KB -