Submission #531249

#TimeUsernameProblemLanguageResultExecution timeMemory
531249penguin133Financial Report (JOI21_financial)C++14
48 / 100
4043 ms1996 KiB
#include <bits/stdc++.h> using namespace std; int dp[300005], A[300005]; int main(){ int n,d; cin >> n >> d; for(int i=1;i<=n;i++)cin >> A[i]; for(int i=1;i<=n;i++){ vector<int>v; for(int j=i-1;j>=1;j--)if(A[j] < A[i])v.push_back(j); int prev = i; for(auto j : v){ if(prev - j > d)break; dp[i] = max(dp[i], dp[j]); prev = j; } dp[i]++; } int ans =0 ; for(int i=1;i<n;i++)ans = max(ans, dp[i]); cout << max(ans, dp[n]); }
#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...