Submission #701696

# Submission time Handle Problem Language Result Execution time Memory
701696 2023-02-22T01:30:55 Z scottchou Preokret (COCI18_preokret) C++17
50 / 50
1 ms 340 KB
#include<bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n;
    vector<pair<int, bool> > a;
    int x, cnt = 0;
    for(int i = 0; i < n; i++){
        cin >> x;
        if(x <= 1440)
            cnt++;
        a.push_back({x, 0});
    }
    cin >> m;
    for(int i = 0; i < m; i++){
        cin >> x;
        if(x <= 1440)
            cnt++;
        a.push_back({x, 1});
    }
    sort(a.begin(), a.end());
    cout << cnt << '\n';
    int aa = !a[0].second, bb = a[0].second;
    bool now_win = a[0].second;
    int cnt2 = 0;
    for(int i = 1; i < a.size(); i++){
        aa += !a[i].second; bb += a[i].second;
        if((aa > bb && now_win) || (aa < bb && !now_win)){
            cnt2++;
            now_win = !now_win;
        }
    }
    cout << cnt2 << '\n';
}

Compilation message

preokret.cpp: In function 'int main()':
preokret.cpp:29:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i = 1; i < a.size(); i++){
      |                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 212 KB Output is correct