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 A[5050], B[5050], C[5050], D[5050];
int n, a;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int i, j, m;
cin >> n;
for (i = 1; i <= n; i++) {
cin >> A[i];
}
for (i = 1; i <= n; i++) {
cin >> B[i];
}
for (i = 1; i <= n; i++) {
for (j = i, m = A[i]; j <= n; j++) {
if (m <= A[j]) C[j] = 1, m = A[j];
else C[j] = 0;
}
for (j = i, m = A[i]; j >= 1; j--) {
if (m <= A[j]) C[j] = 1, m = A[j];
else C[j] = 0;
}
for (j = 1, m = 0; j <= n; j++) {
m = max(m, D[j]);
if (C[j]) D[j] = m + (B[i] == A[j]);
else D[j] = 0;
a = max(a, D[j]);
}
}
cout << a << "\n";
return 0;
}
# | 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... |