#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";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |