#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1e5;
int n;
int a[NMAX + 5], b[NMAX + 5];
int vec[NMAX + 5];
int maxim[15][15];
int val[15];
int ans = 0;
void bkt (int k)
{
if (k > n)
{
for (int i=1; i<=n; i++)
val[i] = a[i];
int curr = 0;
for (int i=1; i<=n; i++)
{
for (int j=i; j<=vec[i]; j++)
val[j] = max(val[j], maxim[i][vec[i]]);
curr += (val[i] == b[i]);
}
ans = max(ans, curr);
}
for (int i=k; i<=n; i++)
{
vec[k] = i;
bkt(k+1);
}
}
int main()
{
cin >> n;
for (int i=1; i<=n; i++)
cin >> a[i];
for (int i=1; i<=n; i++)
cin >> b[i];
bkt(1);
if (n <= 10)
{
for (int i=1; i<=n; i++)
{
maxim[i][i] = a[i];
for (int j=i+1; j<=n; j++)
maxim[i][j] = max(maxim[i][j-1], a[j]);
}
bkt(1);
cout << ans;
return 0;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
536 ms |
308 KB |
Output is correct |
5 |
Correct |
531 ms |
336 KB |
Output is correct |
6 |
Correct |
526 ms |
292 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1085 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
1108 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
536 ms |
308 KB |
Output is correct |
5 |
Correct |
531 ms |
336 KB |
Output is correct |
6 |
Correct |
526 ms |
292 KB |
Output is correct |
7 |
Execution timed out |
1067 ms |
212 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
536 ms |
308 KB |
Output is correct |
5 |
Correct |
531 ms |
336 KB |
Output is correct |
6 |
Correct |
526 ms |
292 KB |
Output is correct |
7 |
Execution timed out |
1085 ms |
212 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |