# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
745317 | rainboy | Exam (eJOI20_exam) | C11 | 6 ms | 6420 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 <stdio.h>
#define N 100000
#define N_ 5000
int max(int a, int b) { return a > b ? a : b; }
int main() {
static int aa[N], bb[N], dp[N_ + 1], ww[N_ + 1][N_ + 1];
int n, i, j, l, r, k, k_;
scanf("%d", &n);
for (i = 0; i < n; i++)
scanf("%d", &aa[i]);
for (i = 0; i < n; i++)
scanf("%d", &bb[i]);
if (n <= N_) {
for (i = 0; i < n; i++) {
k = 0;
for (l = i; l >= 0 && (l == i || aa[l] < aa[i]); l--) {
k_ = k += (bb[l] == aa[i] ? 1 : 0);
for (r = i; r < n && aa[r] <= aa[i]; r++) {
if (r > i)
k_ += (bb[r] == aa[i] ? 1 : 0);
ww[l][r + 1] = k_;
}
}
}
dp[0] = 0;
for (i = 0; i <= n; i++)
for (j = i + 1; j <= n; j++)
dp[j] = max(dp[j], dp[i] + ww[i][j]);
printf("%d\n", dp[n]);
}
return 0;
}
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... |