# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
464306 |
2021-08-12T20:24:46 Z |
AdamGS |
Exam (eJOI20_exam) |
C++14 |
|
289 ms |
165332 KB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=5007;
int a[LIM], b[LIM], dp[LIM][LIM], ma[LIM][LIM];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n;
cin >> n;
rep(i, n) cin >> a[i+1];
rep(i, n) cin >> b[i+1];
rep(i, n) {
for(int j=i; j<n; ++j) {
ma[i+1][j+1]=max(ma[i+1][j], a[j+1]);
}
}
rep(i, n) rep(j, n) {
dp[i+1][j+1]=max(dp[i+1][j], dp[i][j+1]);
if(a[i+1]==b[j+1] && ma[min(i+1, j+1)][max(i+1, j+1)]==a[i+1]) {
dp[i+1][j+1]=max(dp[i+1][j+1], dp[i+1][j]+1);
}
}
cout << dp[n][n] << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
14156 KB |
Output is correct |
2 |
Runtime error |
10 ms |
404 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
4 ms |
5708 KB |
Output is correct |
3 |
Correct |
37 ms |
39828 KB |
Output is correct |
4 |
Correct |
165 ms |
157268 KB |
Output is correct |
5 |
Correct |
175 ms |
165188 KB |
Output is correct |
6 |
Correct |
176 ms |
165188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
176 ms |
165212 KB |
Output is correct |
2 |
Runtime error |
10 ms |
408 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
588 KB |
Output is correct |
9 |
Correct |
1 ms |
1100 KB |
Output is correct |
10 |
Correct |
2 ms |
2124 KB |
Output is correct |
11 |
Correct |
2 ms |
2124 KB |
Output is correct |
12 |
Correct |
2 ms |
2124 KB |
Output is correct |
13 |
Correct |
2 ms |
2124 KB |
Output is correct |
14 |
Correct |
2 ms |
2124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
4 ms |
5708 KB |
Output is correct |
9 |
Correct |
37 ms |
39828 KB |
Output is correct |
10 |
Correct |
165 ms |
157268 KB |
Output is correct |
11 |
Correct |
175 ms |
165188 KB |
Output is correct |
12 |
Correct |
176 ms |
165188 KB |
Output is correct |
13 |
Correct |
0 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
588 KB |
Output is correct |
15 |
Correct |
1 ms |
1100 KB |
Output is correct |
16 |
Correct |
2 ms |
2124 KB |
Output is correct |
17 |
Correct |
2 ms |
2124 KB |
Output is correct |
18 |
Correct |
2 ms |
2124 KB |
Output is correct |
19 |
Correct |
2 ms |
2124 KB |
Output is correct |
20 |
Correct |
2 ms |
2124 KB |
Output is correct |
21 |
Correct |
2 ms |
2124 KB |
Output is correct |
22 |
Correct |
12 ms |
14156 KB |
Output is correct |
23 |
Correct |
289 ms |
165152 KB |
Output is correct |
24 |
Correct |
223 ms |
165252 KB |
Output is correct |
25 |
Correct |
195 ms |
165252 KB |
Output is correct |
26 |
Correct |
183 ms |
165252 KB |
Output is correct |
27 |
Correct |
190 ms |
165196 KB |
Output is correct |
28 |
Correct |
175 ms |
165184 KB |
Output is correct |
29 |
Correct |
177 ms |
165332 KB |
Output is correct |
30 |
Correct |
177 ms |
165188 KB |
Output is correct |
31 |
Correct |
174 ms |
165144 KB |
Output is correct |
32 |
Correct |
177 ms |
165244 KB |
Output is correct |