Submission #446418

# Submission time Handle Problem Language Result Execution time Memory
446418 2021-07-21T21:35:36 Z radaiosm7 Exam (eJOI20_exam) C++
0 / 100
2 ms 332 KB
#include <bits/stdc++.h>
using namespace std;
int n, a[5005], b[5005], i, j, dp[5005], cc;

int main() {
  scanf("%d", &n);

  for (i=1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }

  for (i=1; i <= n; ++i) {
    scanf("%d", &b[i]);
  }

  dp[0] = 0;

  for (i=1; i <= n; ++i) {
    cc = 0;
    dp[i] = 0;

    for (j=i; j > 0; --j) {
      if (a[j] > a[i]) break;
      if (b[j] == a[i]) ++cc;
      dp[i] = max(dp[i], dp[j-1]+cc);
    }
  }

  printf("%d\n", dp[n]);
}

Compilation message

exam.cpp: In function 'int main()':
exam.cpp:6:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
exam.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d", &a[i]);
      |     ~~~~~^~~~~~~~~~~~~
exam.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d", &b[i]);
      |     ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 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 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -