# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
466610 | Error42 | Exam (eJOI20_exam) | C++14 | 68 ms | 98484 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 <iostream>
#include <vector>
using namespace std;
int main()
{
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
vector<int> b(n);
for (int i = 0; i < n; i++)
cin >> b[i];
vector<vector<int>> dp(n, vector<int>(n, 0));
for (int j = 0; j < n; j++) {
dp[0][j] = b[0] == a[j];
}
for (int i = 1; i < n; i++) {
int max_before = max(dp[i - 1][i - 1], dp[i - 1][i]);
dp[i][i] = max_before + (b[i] == a[i]);
for (int j = i + 1; j < n; j++) {
max_before = max(max_before, dp[i - 1][j]);
dp[i][j] = max_before + (b[i] == a[j]);
}
}
#ifdef _DEBUG
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
# | 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... |