Submission #564546

#TimeUsernameProblemLanguageResultExecution timeMemory
564546nikatamlianiFinancial Report (JOI21_financial)C++14
0 / 100
4085 ms1604 KiB
#include <bits/stdc++.h> using namespace std; const int N = 3e5+10; int n, d; int a[N], on[N], rgh[N], dp[N], t[4 * N]; int main() { cin >> n >> d; for (int i = 1; i <= n; ++i) { cin >> a[i]; } for (int i = 1; i <= n; ++i) { int count = 0, pos = rgh[i] = i; for (int j = i + 1; j <= n; ++j) { if (j - pos > d) break; if (a[j] <= a[i]) pos = j; rgh[i] = j; } } int best = 0; rgh[0] = n; for (int i = 1; i <= n; ++i) { for (int j = 0; j < i; ++j) { if (rgh[j] >= i && a[j] < a[i]) { dp[i] = max(dp[i], dp[j] + 1); } } best = max(best, dp[i]); } cout << best << endl; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:12:13: warning: unused variable 'count' [-Wunused-variable]
   12 |         int count = 0, pos = rgh[i] = 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...