# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
446418 | radaiosm7 | Exam (eJOI20_exam) | C++98 | 2 ms | 332 KiB |
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 n, a[5005], b[5005], i, j, dp[5005], cc;
int main() {
scanf("%d", &n);
for (i=1; i <= n; ++i) {
scanf("%d", &a[i]);
}
for (i=1; i <= n; ++i) {
scanf("%d", &b[i]);
}
dp[0] = 0;
for (i=1; i <= n; ++i) {
cc = 0;
dp[i] = 0;
for (j=i; j > 0; --j) {
if (a[j] > a[i]) break;
if (b[j] == a[i]) ++cc;
dp[i] = max(dp[i], dp[j-1]+cc);
}
}
printf("%d\n", dp[n]);
}
Compilation message (stderr)
# | 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... |