답안 #161700

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

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 248 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 248 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 0 ms 376 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Incorrect 3 ms 376 KB Output isn't 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 248 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 0 ms 376 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Incorrect 3 ms 376 KB Output isn't correct