Submission #446418

#TimeUsernameProblemLanguageResultExecution timeMemory
446418radaiosm7Exam (eJOI20_exam)C++98
0 / 100
2 ms332 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...