Submission #928373

# Submission time Handle Problem Language Result Execution time Memory
928373 2024-02-16T09:22:15 Z Aiperiii Sure Bet (CEOI17_sure) C++14
60 / 100
2000 ms 6976 KB
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
const int N=1e5+5;
signed main(){
    int n;
    cin>>n;
    vector <long double> a(n),b(n);
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    sort(all(a));sort(all(b));
    for(int i=n-2;i>=0;i--){
        a[i]+=a[i+1];
        b[i]+=b[i+1];
    }
    a.pb(0);
    b.pb(0);
    
    long double ans=-1e9;
    for(int i=n;i>=0;i--){
        for(int j=n;j>=0;j--){
            long double sum1=a[i],sum2=b[j];
            long double cnt1=n-i,cnt2=n-j;
            long double x=min(sum1-cnt1-cnt2,sum2-cnt1-cnt2);
            ans=max(ans,x);
        }
    }
    if(ans<0)ans=0;
    cout<<fixed<<setprecision(4)<<ans<<"\n";
}
/*
4
1.4 3.7
1.2 2
1.6 1.4
1.9 1.5
 */
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 5 ms 348 KB Output is correct
13 Correct 5 ms 344 KB Output is correct
14 Correct 5 ms 348 KB Output is correct
15 Correct 5 ms 348 KB Output is correct
16 Correct 5 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 5 ms 348 KB Output is correct
13 Correct 5 ms 344 KB Output is correct
14 Correct 5 ms 348 KB Output is correct
15 Correct 5 ms 348 KB Output is correct
16 Correct 5 ms 344 KB Output is correct
17 Execution timed out 2067 ms 6976 KB Time limit exceeded
18 Halted 0 ms 0 KB -