Submission #406330

# Submission time Handle Problem Language Result Execution time Memory
406330 2021-05-17T11:39:09 Z MilosMilutinovic Exam (eJOI20_exam) C++14
0 / 100
1000 ms 716 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 5005;

int a[N];
int b[N];
int dp[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    map<int, int> cnt;
    int mx = a[i];
    for (int j = i;j >= 0; j--) {
      mx = max(mx, a[j]);
      cnt[b[j]]++;
      dp[i] = max(dp[i], (j == 0 ? 0 : dp[j - 1]) + cnt[mx]);
    }
  }
  cout << dp[n - 1] << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Incorrect 1 ms 320 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 332 KB Output is correct
2 Runtime error 2 ms 716 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 660 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Incorrect 1 ms 320 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 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Incorrect 1 ms 320 KB Output isn't correct
6 Halted 0 ms 0 KB -