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()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n; cin>>n;
if(n>10) cout<<"bruuuuuuuuuuuuh";
else
{
vector<int> a(n), b(n), c(n);
for(int i=0; i<n; i++) cin>>a[i], c[i]=a[i];
for(int i=0; i<n; i++) cin>>b[i];
int ans=0;
for(int i=1; i<=1<<n; i++)
{
a=c;
int flag=1, p=0;;
for(int l=0; l<n&&flag; l++)
{
if(a[l]>b[l]&&(i&(1<<l))) flag=0;
else if(i&(1<<l)){
p++;
int j=l;
if(a[l]==b[l]) continue;
int val=a[l];
if(j>0){
while(val<b[l])
{
if(i&(1<<j)&&b[l]!=b[j]) break;
val=max(val, a[j]);
if(j==0||val==b[l]) break;
else j--;
}}
if(val!=b[l])
{
j=l+1;
val=a[l];
while(val<b[l])
{
val=max(val, a[j]);
if(j==n-1||val==b[l]) break;
else j++;
}
if(val!=b[l]) flag=0;
else
{
for(int k=l; k<=j; k++)
a[k]=val;
}
}
}
}
if(flag) ans=max(ans, p);
}
cout<<ans<<"\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |