답안 #45458

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
45458 2018-04-14T07:17:11 Z nickyrio Sure Bet (CEOI17_sure) C++17
100 / 100
127 ms 2488 KB
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, a) for (int i = 0; i < (a); ++i)
#define DEBUG(x) { cerr << #x << '=' << x << endl; }
#define Arr(a, l, r) { cerr << #a << " = {"; FOR(_, l, r) cerr << ' ' << a[_]; cerr << "}\n"; }
#define N 1001000
#define pp pair<int, int>
#define endl '\n'
#define IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define taskname ""
#define bit(S, i) (((S) >> (i)) & 1)
using namespace std;

double a[N], b[N];

int main() {
    #ifdef NERO
    freopen("test.inp","r",stdin);
    freopen("test.out","w",stdout);
    double stime = clock();
    #else 
        //freopen(taskname".inp","r",stdin);
        //freopen(taskname".out","w",stdout);
    #endif //NERO
    IO;
    int n;
    cin >> n;
    FOR(i, 1, n) cin >> a[i] >> b[i];
    sort(a + 1, a + n + 1, greater<double>());
    sort(b + 1, b + n + 1, greater<double>());
    double ans = 0, sa = 0, sb = 0;
    int na = 0, nb = 0;
    FOR(buy, 1, n * 2) {
        if ((sa < sb && na < n) || sb == n) sa += a[++na];
        else sb += b[++nb];
        ans = max(ans, min(sa, sb) - 1.0 * buy);
    }
    cout << fixed << setprecision(4) << ans;
    #ifdef NERO
    double etime = clock();
    cerr << "Execution time: " << (etime - stime) / CLOCKS_PER_SEC * 1000 << " ms.\n";
    #endif // NERO
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 568 KB Output is correct
4 Correct 2 ms 568 KB Output is correct
5 Correct 2 ms 568 KB Output is correct
6 Correct 2 ms 572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 568 KB Output is correct
4 Correct 2 ms 568 KB Output is correct
5 Correct 2 ms 568 KB Output is correct
6 Correct 2 ms 572 KB Output is correct
7 Correct 2 ms 624 KB Output is correct
8 Correct 2 ms 624 KB Output is correct
9 Correct 2 ms 628 KB Output is correct
10 Correct 2 ms 632 KB Output is correct
11 Correct 2 ms 652 KB Output is correct
12 Correct 3 ms 652 KB Output is correct
13 Correct 4 ms 672 KB Output is correct
14 Correct 3 ms 688 KB Output is correct
15 Correct 3 ms 704 KB Output is correct
16 Correct 3 ms 720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 568 KB Output is correct
4 Correct 2 ms 568 KB Output is correct
5 Correct 2 ms 568 KB Output is correct
6 Correct 2 ms 572 KB Output is correct
7 Correct 2 ms 624 KB Output is correct
8 Correct 2 ms 624 KB Output is correct
9 Correct 2 ms 628 KB Output is correct
10 Correct 2 ms 632 KB Output is correct
11 Correct 2 ms 652 KB Output is correct
12 Correct 3 ms 652 KB Output is correct
13 Correct 4 ms 672 KB Output is correct
14 Correct 3 ms 688 KB Output is correct
15 Correct 3 ms 704 KB Output is correct
16 Correct 3 ms 720 KB Output is correct
17 Correct 108 ms 2472 KB Output is correct
18 Correct 99 ms 2472 KB Output is correct
19 Correct 98 ms 2472 KB Output is correct
20 Correct 127 ms 2476 KB Output is correct
21 Correct 107 ms 2476 KB Output is correct
22 Correct 99 ms 2476 KB Output is correct
23 Correct 101 ms 2476 KB Output is correct
24 Correct 103 ms 2476 KB Output is correct
25 Correct 105 ms 2476 KB Output is correct
26 Correct 107 ms 2488 KB Output is correct