답안 #570922

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
570922 2022-05-31T14:28:02 Z nttt Sure Bet (CEOI17_sure) C++14
100 / 100
86 ms 3216 KB
#include<bits/stdc++.h>
using namespace std;
#define MASK(i) (1LL << (i))
#define BIT(x, i) ((x >> (i)) & 1)
#define fi first
#define se second
#define ll long long
#define task "name" 

const int oo = 1e9 + 7;
const ll loo = (ll)1e18 + 7;
const int MOD = 1e9 + 7;
const int N = 1e5 + 3;
const int BASE = 10;

template <typename T1, typename T2> bool minimize(T1 &a, T2 b)
{
    if (a > b) {a = b; return true;} return false;
}
template <typename T1, typename T2> bool maximize(T1 &a, T2 b)
{
    if (a < b) {a = b; return true;} return false;
}

int n;
double a[N], b[N];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(task".inp" , "r" , stdin);
    //freopen(task".out" , "w" , stdout);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
    sort(a + 1, a + 1 + n, greater<double>());
    sort(b + 1, b + 1 + n, greater<double>());
    double sum_a = 0, sum_b = 0, ans = 0;
    int i = 1, j = 1;
    while(i <= n || j <= n)
    {
        if(i <= n && sum_a <= sum_b) sum_a += a[i++];
        else if(j <= n && sum_b < sum_a) sum_b += b[j++];
        else break;
        maximize(ans, min(sum_a, sum_b) - i - j + 2);
    }
    cout << fixed << setprecision(4) << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 328 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 79 ms 2768 KB Output is correct
18 Correct 76 ms 2740 KB Output is correct
19 Correct 72 ms 2784 KB Output is correct
20 Correct 78 ms 2748 KB Output is correct
21 Correct 86 ms 3212 KB Output is correct
22 Correct 86 ms 2732 KB Output is correct
23 Correct 78 ms 2800 KB Output is correct
24 Correct 81 ms 2784 KB Output is correct
25 Correct 86 ms 2816 KB Output is correct
26 Correct 83 ms 3216 KB Output is correct