Submission #143271

#TimeUsernameProblemLanguageResultExecution timeMemory
143271grobarPreokret (COCI18_preokret)C++14
50 / 50
3 ms376 KiB
#include <bits/stdc++.h> using namespace std; int main() { vector< pair<int,char> >par; int n; cin>>n; int a[n]; int k=0; for(int i=0;i<n;i++) { cin>>a[i]; par.push_back(make_pair(a[i],'A')); if(a[i]<=60*12*2) { k++; } } int m; cin>>m; int b[m]; for(int i=0;i<m;i++) { cin>>b[i]; par.push_back(make_pair(b[i],'B')); if(b[i]<=60*12*2) { k++; } } sort(par.begin(),par.end()); int va=0; int vb=0; int preokret=0; int suma=0; int sumb=0; for(int i=0;i<par.size();i++) { if(par[i].second=='A') { suma++; if(suma>sumb && va==0 && vb==0) { va=1; } if(suma>sumb && vb==1) { preokret++; vb=0; va=1; } } if(par[i].second=='B') { sumb++; if(sumb>suma && va==0 && vb==0) { vb=1; } if(sumb>suma && va==1) { preokret++; va=0; vb=1; } } } cout<<k<<endl; cout<<preokret<<endl; }

Compilation message (stderr)

preokret.cpp: In function 'int main()':
preokret.cpp:39:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<par.size();i++)
                 ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...