# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
152826 | AldeaDanut | Preokret (COCI18_preokret) | C++14 | 3 ms | 380 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>
#define x first
#define y second
using namespace std;
int a,b,A[3000],B[3000],cnt,i,j,n,s[3],lead;
pair <int,int> v[6000];
int main(){
cin>>a;
for(i=1;i<=a;i++)
cin>>A[i];
cin>>b;
for(i=1;i<=b;i++)
cin>>B[i];
int ok=1;
for(i=1,j=1;i<=a&&j<=b;){
if(A[i]<B[j]){
n++;
v[n].x=A[i];
v[n].y=0;
i++;
}else{
n++;
v[n].x=B[j];
v[n].y=1;
j++;
}
if(v[n].x>1440 && ok)
cout<<n-1<<"\n",ok=0;
}
if(ok)
cout<<n<<"\n";
for(;i<=a;i++)
v[++n].x=A[i],v[n].y=0;
for(;j<=b;j++)
v[++n].x=B[j],v[n].y=1;
lead=v[1].y;
s[lead]++;
for(i=2;i<=n;i++){
s[v[i].y]++;
if(s[lead]<s[1-lead]){
cnt++;
lead=1-lead;
//cout<<v[i].x<<"-";
}
}
cout<<cnt;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |