Submission #600429

#TimeUsernameProblemLanguageResultExecution timeMemory
600429PlurmFinancial Report (JOI21_financial)C++11
28 / 100
50 ms952 KiB
#include <bits/stdc++.h> using namespace std; int a[405]; int dp[405][405]; // dp[last][max] int main(){ int n, d; scanf("%d%d",&n,&d); for(int i = 1; i <= n; i++){ scanf("%d", a+i); } for(int i = 1; i <= n; i++){ for(int j = 1; j < i; j++){ if(a[j] < a[i]) continue; // dp[i][j] <- dp[k][j] for(int k = i-1; k >= i-d && k > 0; k--){ if(a[j] < a[k]) continue; dp[i][j] = max(dp[i][j], dp[k][j]); } } // dp[i][i] dp[i][i] = 1; for(int k = i-1; k >= i-d && k > 0; k--){ for(int j = 0; j <= k; j++){ if(a[j] >= a[i]) continue; dp[i][i] = max(dp[i][i], dp[k][j] + 1); } } } int ans = 0; for(int j = 0; j <= n; j++) ans = max(ans, dp[n][j]); printf("%d\n", ans); return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:9:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |   scanf("%d%d",&n,&d);
      |   ~~~~~^~~~~~~~~~~~~~
Main.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d", a+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...