Submission #637115

# Submission time Handle Problem Language Result Execution time Memory
637115 2022-08-31T15:19:15 Z Ahmed57 Preokret (COCI18_preokret) C++14
50 / 50
1 ms 340 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    int a,b;
    cin>>a;
    vector<pair<int,int>> v;
    int col = 0;
    for(int i = 0;i<a;i++){
        int x;cin>>x;
        v.push_back({x,0});
        if(x<=1440)col++;
    }
    cin>>b;
    for(int i = 0;i<b;i++){
        int x;cin>>x;
        v.push_back({x,1});
        if(x<=1440)col++;
    }
    sort(v.begin(),v.end());
    cout<<col<<"\n";
    vector<pair<int,int>>z;
    int x = 0,y = 0 , ans = 0;
    for(int i = 0;i<a+b;i++){
        if(v[i].second==0)x++;
        else y++;
        if(x!=y)z.push_back({x,y});
    }
    for(int i = 1;i<z.size();i++){
        if((z[i-1].first<z[i-1].second)!=(z[i].first<z[i].second))ans++;
    }
    cout<<ans<<"\n";
}

Compilation message

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