Submission #841548

# Submission time Handle Problem Language Result Execution time Memory
841548 2023-09-01T16:27:29 Z treewave Sure Bet (CEOI17_sure) C++17
60 / 100
33 ms 3540 KB
#include <bits/stdc++.h>

using namespace std;

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

    int n; cin >> n;
    vector<long long> a(n), b(n);
    for (int i = 0; i < n; i++){
        string x, y; cin >> x >> y;
        if (find(x.begin(), x.end(), '.') == x.end()) x += '.';
        if (find(y.begin(), y.end(), '.') == y.end()) y += '.';
        int fpoint_idx = find(x.begin(), x.end(), '.') - x.begin();
        int mv = 0;
        for (int j = fpoint_idx; j < x.size() - 1; j++){
            swap(x[j], x[j+1]);
            mv++;
        }
        x.pop_back();
        for (; mv <= 4; mv++){
            x += '0';
        }
        mv = 0;
        fpoint_idx = find(y.begin(), y.end(), '.') - y.begin();
        for (int j = fpoint_idx; j < y.size() - 1; j++){
            swap(y[j], y[j+1]);
            mv++;
        }
        y.pop_back();
        for (; mv <= 4; mv++){
            y += '0';
        }
        a[i] = stoll(x); b[i] = stoll(y);
    }
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());

    long long ans = 0, sa = 0, sb = 0, ptr_a = 0, ptr_b = 0;
    for (long long i = 1; i <= 2 * n; i++){
        if (sa < sb && ptr_a != n){
            sa += a[ptr_a];
            ptr_a++;
        }
        else{
            sb += b[ptr_b];
            ptr_b++;
        }
        ans = max(ans, min(sa, sb) - i * 100000);
    }
    printf("%.4Lf\n", ((long double) ans) / 100000);
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:17:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         for (int j = fpoint_idx; j < x.size() - 1; j++){
      |                                  ~~^~~~~~~~~~~~~~
sure.cpp:27:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         for (int j = fpoint_idx; j < y.size() - 1; j++){
      |                                  ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 220 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 220 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 228 KB Output is correct
11 Correct 0 ms 228 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 352 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 352 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 220 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 220 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 228 KB Output is correct
11 Correct 0 ms 228 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 352 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 352 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 31 ms 3260 KB Output is correct
18 Correct 31 ms 3160 KB Output is correct
19 Correct 31 ms 3160 KB Output is correct
20 Correct 32 ms 3252 KB Output is correct
21 Incorrect 33 ms 3540 KB Output isn't correct
22 Halted 0 ms 0 KB -