# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
833412 |
2023-08-22T05:26:44 Z |
vjudge1 |
Exam (eJOI20_exam) |
C++17 |
|
1000 ms |
196716 KB |
#include<bits/stdc++.h>
#define int long long
#define For(i, n) for (int i = 0; i < n; i++)
using namespace std;
const int MAXN = 5e3;
int N, H[MAXN + 5], T[MAXN + 5], dp[MAXN + 5][MAXN + 5];
int f(int L, int R) {
if (L > R) return 0;
if (L == R) {
if (H[L] == T[L]) return 1;
else return 0;
}
// menjadikan semuanya max(H[l], H[l+1], .. , H[r])
int maks = 0;
for (int i = L; i <= R; i++) {
maks = max(maks, H[i]);
}
int cnt = 0;
for (int i = L; i <= R; i++) {
if (T[i] == maks) cnt++;
}
int ans = cnt;
for (int i = L; i <= R - 1; i++) {
ans = max(ans, f(L, i) + f(i + 1, R));
}
return dp[L][R] = ans;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
memset(dp, -1, sizeof dp);
cin >> N;
For (i, N) cin >> H[i];
For (i, N) cin >> T[i];
cout << f(0, N - 1) << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
196324 KB |
Output is correct |
2 |
Correct |
59 ms |
196316 KB |
Output is correct |
3 |
Correct |
60 ms |
196300 KB |
Output is correct |
4 |
Correct |
60 ms |
196344 KB |
Output is correct |
5 |
Incorrect |
60 ms |
196300 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1057 ms |
196428 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
60 ms |
196376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1048 ms |
196716 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
196324 KB |
Output is correct |
2 |
Correct |
59 ms |
196316 KB |
Output is correct |
3 |
Correct |
60 ms |
196300 KB |
Output is correct |
4 |
Correct |
60 ms |
196344 KB |
Output is correct |
5 |
Incorrect |
60 ms |
196300 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
196324 KB |
Output is correct |
2 |
Correct |
59 ms |
196316 KB |
Output is correct |
3 |
Correct |
60 ms |
196300 KB |
Output is correct |
4 |
Correct |
60 ms |
196344 KB |
Output is correct |
5 |
Incorrect |
60 ms |
196300 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |