# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
143271 | 2019-08-13T13:29:26 Z | grobar | Preokret (COCI18_preokret) | C++14 | 3 ms | 376 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 3 ms | 376 KB | Output is correct |
7 | Correct | 3 ms | 376 KB | Output is correct |
8 | Correct | 3 ms | 376 KB | Output is correct |
9 | Correct | 3 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |