Submission #745317

#TimeUsernameProblemLanguageResultExecution timeMemory
745317rainboyExam (eJOI20_exam)C11
0 / 100
6 ms6420 KiB
#include <stdio.h> #define N 100000 #define N_ 5000 int max(int a, int b) { return a > b ? a : b; } int main() { static int aa[N], bb[N], dp[N_ + 1], ww[N_ + 1][N_ + 1]; int n, i, j, l, r, k, k_; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &aa[i]); for (i = 0; i < n; i++) scanf("%d", &bb[i]); if (n <= N_) { for (i = 0; i < n; i++) { k = 0; for (l = i; l >= 0 && (l == i || aa[l] < aa[i]); l--) { k_ = k += (bb[l] == aa[i] ? 1 : 0); for (r = i; r < n && aa[r] <= aa[i]; r++) { if (r > i) k_ += (bb[r] == aa[i] ? 1 : 0); ww[l][r + 1] = k_; } } } dp[0] = 0; for (i = 0; i <= n; i++) for (j = i + 1; j <= n; j++) dp[j] = max(dp[j], dp[i] + ww[i][j]); printf("%d\n", dp[n]); } return 0; }

Compilation message (stderr)

exam.c: In function 'main':
exam.c:12:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
exam.c:14:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
exam.c:16:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d", &bb[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...