# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
833289 | vjudge1 | Exam (eJOI20_exam) | C++17 | 1074 ms | 628 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 <bits/stdc++.h>
using namespace std;
int n;
int h[100005];
int t[100005];
int dp[100005];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> h[i];
}
for (int i = 0; i < n; i++) {
cin >> t[i];
}
// subtask 3
int ans = 0;
dp[n] = 0;
for (int i = n - 1; i >= 0; i--) {
int maxx = 0, cnt = 0;
map<int,int> mp;
for (int j = i; j < n; j++) {
mp[t[j]]++;
dp[i] = max(dp[i], dp[j + 1] + mp[h[j]]);
}
dp[i] = max(dp[i], dp[i + 1]);
ans = max(ans, dp[i]);
}
cout << ans << '\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... |