Submission #637115

#TimeUsernameProblemLanguageResultExecution timeMemory
637115Ahmed57Preokret (COCI18_preokret)C++14
50 / 50
1 ms340 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...