# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
166058 | itiam | Preokret (COCI18_preokret) | C++11 | 5 ms | 504 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 <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int La[2283],Lb[2283];
int main(){
int Na,Nb,x,m=0,mm,pp=0,brop=0; //pp=prije poluvremena, brop=brojac preokreta, m=max, mm=minimal..
cin >> Na;
for (int i=0;i<Na;i++){
cin >> x;
if (x>m) m=x;
if (x<mm || i==0) mm=x;
if (x<=1440) pp+=1;
La[x]=1;
}
cin >> Nb;
for (int i=0;i<Nb;i++){
cin >> x;
if (x>m) m=x;
if (x<mm) mm=x;
if (x<=1440) pp+=1;
Lb[x]=1;
}
int p=0,pv;
if (La[mm]==1) pv=-1;
else if (Lb[mm]==1) pv=1;
for (int i=mm;i<=m;i++){
if (La[i]==1){
p+=1;
}
else if (Lb[i]==1){
p-=1;
}
if (p*pv>0){
brop+=1;
pv*=-1;
}
}
cout << pp << "\n";
cout << brop;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |