Submission #281836

# Submission time Handle Problem Language Result Execution time Memory
281836 2020-08-23T14:25:19 Z neki Sure Bet (CEOI17_sure) C++14
100 / 100
265 ms 5496 KB
#include <bits/stdc++.h>
#define loop(i, a, b) for(long long i=a;i<b;i++)
#define pool(i, a, b) for(long long i=a-1;i>=b;i--)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define vc vector
#define pa pair<ll, ll>
#define ll long long
#define all(a) a.begin(), a.end()
using namespace std;
#define mn 201000
#define pa pair<ll, ll>
#define ld long double
ld a[mn], b[mn];
ld min(ld a, ld b){return (a<b) ? a:b;}
ld max(ld a, ld b){return (a>b) ? a:b;}
int main(){
    ll n;cin >> n;
    loop(i, 1, n+1) cin >> a[i]>>b[i];
    sort(a+1, a+n+1, greater<ld> ()); loop(i, 1, n+1) a[i]+=a[i-1];
    sort(b+1, b+n+1, greater<ld> ()); loop(i, 1, n+1) b[i]+=b[i-1];
    ld ans=0.0;
    ll j=0;
    loop(i, 0, n+1){
        while(j<n and min(a[i], b[j])-(ld)i-(ld)j<=min(a[i], b[j+1])-(ld)i-(ld)j-(ld)1) j++;
        ans=max(ans, min(a[i], b[j])-(ld)i-(ld)j);
    }
    cout << fixed << setprecision(4)<<ans<<endl;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 232 ms 4828 KB Output is correct
18 Correct 238 ms 4864 KB Output is correct
19 Correct 233 ms 4976 KB Output is correct
20 Correct 241 ms 4968 KB Output is correct
21 Correct 259 ms 5212 KB Output is correct
22 Correct 232 ms 4856 KB Output is correct
23 Correct 230 ms 4984 KB Output is correct
24 Correct 230 ms 4984 KB Output is correct
25 Correct 229 ms 4820 KB Output is correct
26 Correct 265 ms 5496 KB Output is correct