답안 #97286

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
97286 2019-02-14T18:44:57 Z dalgerok Sure Bet (CEOI17_sure) C++14
100 / 100
133 ms 3832 KB
#include<bits/stdc++.h>
using namespace std;



const int N = 1e5 + 5;



int n;
double a[N], b[N];



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i] >> b[i];
        a[i] -= 1;
        b[i] -= 1;
    }
    sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);
    sort(b + 1, b + n + 1);
    reverse(b + 1, b + n + 1);
    double ans = 0, sum_a = 0, sum_b = 0;
    for(int na = 0, nb = 0; na <= n; na++){
        if(na){
            sum_a += a[na];
        }
        while(nb + 1 <= n && min(sum_a - nb, sum_b - na) < min(sum_a - (nb + 1), sum_b + a[nb + 1] - na)){
            sum_b += b[nb + 1];
            nb += 1;
        }
        //cout << sum_a << " " << sum_b << " " << na << " " << nb << "\n";
        ans = max(ans, min(sum_a - nb, sum_b - na));
    }
    cout << fixed << setprecision(4) << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 284 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 284 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 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 4 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 284 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 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 4 ms 512 KB Output is correct
17 Correct 108 ms 3360 KB Output is correct
18 Correct 133 ms 3324 KB Output is correct
19 Correct 112 ms 3356 KB Output is correct
20 Correct 96 ms 3244 KB Output is correct
21 Correct 96 ms 3832 KB Output is correct
22 Correct 129 ms 3320 KB Output is correct
23 Correct 99 ms 3320 KB Output is correct
24 Correct 97 ms 3324 KB Output is correct
25 Correct 106 ms 3320 KB Output is correct
26 Correct 100 ms 3676 KB Output is correct