답안 #939559

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
939559 2024-03-06T13:59:12 Z phoenix0423 Sure Bet (CEOI17_sure) C++17
100 / 100
69 ms 3664 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define int long long
const int maxn = 2e5 + 5;

signed main(void){
    fastio;
    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>());
    int id = 0, id2 = 0;
    double ta = 0, tb = 0;
    double ans = 0;
    for(int i = 0; i < 2 * n; i++){
        if(id < n && ta <= tb){
            ta += a[id++];
        }
        else if(id2 < n && tb <= ta){
            tb += b[id2++];
        }
        else break;
        ans = max(ans, min(ta, tb) - i - 1);
    }
    cout<<fixed<<setprecision(4)<<ans<<"\n";
}
# 결과 실행 시간 메모리 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 600 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 600 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 344 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 344 KB Output is correct
11 Correct 0 ms 500 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 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 600 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 344 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 344 KB Output is correct
11 Correct 0 ms 500 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 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 57 ms 3152 KB Output is correct
18 Correct 69 ms 3152 KB Output is correct
19 Correct 58 ms 3280 KB Output is correct
20 Correct 57 ms 3156 KB Output is correct
21 Correct 60 ms 3548 KB Output is correct
22 Correct 57 ms 3152 KB Output is correct
23 Correct 57 ms 3156 KB Output is correct
24 Correct 56 ms 3152 KB Output is correct
25 Correct 57 ms 3384 KB Output is correct
26 Correct 65 ms 3664 KB Output is correct