답안 #161701

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
161701 2019-11-03T18:55:05 Z Minnakhmetov Sure Bet (CEOI17_sure) C++14
100 / 100
175 ms 11656 KB
#include <bits/stdc++.h>
    
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
 
using namespace std;

#define int long long

int getInt(string s) {
    int x = 0;
    for (char c : s) {
        if (c != '.')
            x = x * 10 + c - '0';
    }


    int y = 0;
    while (*(s.end() - y - 1) != '.')
        y++;

    while (y++ < 4)
        x *= 10;

    return x;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    int n;
    cin >> n;

    multiset<int> sta, stb;

    for (int i = 0; i < n; i++) {
        string a, b;
        cin >> a >> b;

        // cout << getInt(a) << " " << getInt(b) << "\n";

        sta.insert(getInt(a));
        stb.insert(getInt(b));
    }

    int sa = 0, sb = 0, ans = 0;
    for (int i = 1; i <= 2 * n; i++) {
        if (sa > sb) {
            if (stb.empty())
                break;
            sb += *stb.rbegin();
            stb.erase(prev(stb.end()));
        }
        else {
            if (sta.empty())
                break;
            sa += *sta.rbegin();
            sta.erase(prev(sta.end()));   
        }

        ans = max(ans, min(sa, sb) - i * 10000);
    }

    string s;

    while (ans > 0) {
        s.push_back(ans % 10 + '0');
        ans /= 10;
    }

    while (s.size() < 5)
        s.push_back('0');

    reverse(all(s));

    s.insert(s.end() - 4, '.');

    cout << s;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 504 KB Output is correct
17 Correct 136 ms 11100 KB Output is correct
18 Correct 168 ms 11100 KB Output is correct
19 Correct 149 ms 11168 KB Output is correct
20 Correct 160 ms 11180 KB Output is correct
21 Correct 126 ms 11636 KB Output is correct
22 Correct 137 ms 11116 KB Output is correct
23 Correct 175 ms 11128 KB Output is correct
24 Correct 145 ms 11152 KB Output is correct
25 Correct 157 ms 11064 KB Output is correct
26 Correct 158 ms 11656 KB Output is correct