답안 #860173

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
860173 2023-10-12T02:32:46 Z Nhoksocqt1 Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 604 KB
#include<bits/stdc++.h>
using namespace std;

#define inf 0x3f3f3f3f
#define sz(x) int((x).size())
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int Random(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

const int MAXN = 100005;

double a[MAXN], b[MAXN];
int nArr;

void process(void) {
    cin >> nArr;
    for (int i = 1; i <= nArr; ++i)
        cin >> a[i] >> b[i];

    sort(a + 1, a + nArr + 1);
    sort(b + 1, b + nArr + 1);

    double res(0), sumA(0), sumB(0);
    int i(nArr), j(nArr);
    while(max(i, j) > 0) {
        if(sumA <= sumB) {
            sumA += a[i--];
        } else {
            sumB += b[j--];
        }

        res = max(res, min(sumA, sumB) - 2 * nArr + i + j);
    }

    cout << setprecision(4) << fixed << res << '\n';
}

int main(void) {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    process();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Runtime error 1 ms 604 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Runtime error 1 ms 604 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Runtime error 1 ms 604 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -