답안 #866575

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
866575 2023-10-26T12:26:01 Z 12345678 Sure Bet (CEOI17_sure) C++17
100 / 100
74 ms 3920 KB
#include <bits/stdc++.h>

using namespace std;

int n;
double ans;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    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()); reverse(a.begin(), a.end());
    sort(b.begin(), b.end()); reverse(b.begin(), b.end());
    for (int i=1; i<n; i++) a[i]+=a[i-1], b[i]+=b[i-1];
    for (int i=0; i<n; i++) 
    {
        if (a[i]>b[n-1]) continue;
        ans=max(ans, a[i]-(lower_bound(b.begin(), b.end(), a[i])-b.begin())-2-i);
    }
    for (int i=0; i<n; i++) 
    {
        if (b[i]>a[n-1]) continue;
        ans=max(ans, b[i]-(lower_bound(a.begin(), a.end(), b[i])-a.begin())-2-i);
    }
    printf("%.4lf", ans);
}
# 결과 실행 시간 메모리 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 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 348 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 456 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 464 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 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 348 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 456 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 464 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 68 ms 3388 KB Output is correct
18 Correct 68 ms 3380 KB Output is correct
19 Correct 69 ms 3148 KB Output is correct
20 Correct 65 ms 3164 KB Output is correct
21 Correct 74 ms 3760 KB Output is correct
22 Correct 68 ms 3148 KB Output is correct
23 Correct 68 ms 3152 KB Output is correct
24 Correct 68 ms 3172 KB Output is correct
25 Correct 66 ms 3296 KB Output is correct
26 Correct 71 ms 3920 KB Output is correct