# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
588481 |
2022-07-03T11:03:32 Z |
berr |
Exam (eJOI20_exam) |
C++17 |
|
1 ms |
212 KB |
#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-1;
if(a[l]==b[l]) continue;
int val=a[l];
if(j>=0){
while(val<b[l])
{
if(i&(1<<j)&&max(val, a[j])!=b[l]) 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];
if(j<n){
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;
}
}
else a[l]=b[l];
}
}
for(int l=0; l<n; l++)
{
if(a[l]!=b[l]&&(i&(1<<l))) flag=0;
}
if(flag)
ans=max(ans, p);
}
cout<<ans<<"\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |