Submission #846952

#TimeUsernameProblemLanguageResultExecution timeMemory
846952SUNWOOOOOOOOFinancial Report (JOI21_financial)C++17
14 / 100
348 ms779600 KiB
#include <bits/stdc++.h> using namespace std; const int mxN = 7005; int n, d, A[mxN], dp1[mxN][mxN], dp2[mxN][mxN]; // len, last idx vector <int> va; int main() { memset(dp1, -1, sizeof dp1); memset(dp2, -1, sizeof dp2); scanf("%d %d", &n, &d); for (int i = 1; i <= n; i++) { scanf("%d", &A[i]); va.push_back(A[i]); } sort(va.begin(), va.end()); va.erase(unique(va.begin(), va.end()), va.end()); for (int i = 1; i <= n; i++) A[i] = lower_bound(va.begin(), va.end(), A[i]) - va.begin() + 1; int ans = 0; for (int i = 1; i <= n; i++){ dp1[i][A[i]] = 1, dp2[i][A[i]] = i; if (dp1[i - 1][A[i]] != -1 && i - dp2[i - 1][A[i]] <= d) dp1[i][A[i]] = dp1[i - 1][A[i]]; for (int j = 1; j < A[i]; j++){ if (dp1[i - 1][j] == -1 || i - dp2[i - 1][j] > d) continue; dp1[i][j] = dp1[i - 1][j], dp2[i][j] = dp2[i - 1][j]; dp1[i][A[i]] = max(dp1[i][A[i]], dp1[i - 1][j] + 1); } for (int j = A[i] + 1; j <= n; j++){ if (dp1[i - 1][j] == -1) continue; dp1[i][j] = dp1[i - 1][j]; dp2[i][j] = i; } for (int j = 1; j <= n; j++) ans = max(ans, dp1[i][j]); } printf("%d\n", ans); return 0; }

Compilation message (stderr)

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