# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
143271 | grobar | Preokret (COCI18_preokret) | C++14 | 3 ms | 376 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |