# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
466610 |
2021-08-19T18:28:30 Z |
Error42 |
Exam (eJOI20_exam) |
C++14 |
|
68 ms |
98484 KB |
#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++) {
cout << dp[i][j] << " ";
}
cout << "\n";
}
#endif // _DEBUG
cout << dp.back().back() << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4172 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
1228 KB |
Output is correct |
3 |
Correct |
14 ms |
16076 KB |
Output is correct |
4 |
Correct |
63 ms |
90736 KB |
Output is correct |
5 |
Correct |
66 ms |
98388 KB |
Output is correct |
6 |
Correct |
68 ms |
98372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
68 ms |
98484 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |