제출 #635887

#제출 시각아이디문제언어결과실행 시간메모리
635887shafinalamFinancial Report (JOI21_financial)C++14
48 / 100
4086 ms5832 KiB
#include <bits/stdc++.h> using namespace std; int dp[300010]; int n, d; int a[300010]; int solve(int i) { if(i==n) { return 1; } int &ret = dp[i]; if(ret != -1){ return ret; } ret = 0; int last = i; for(int j=i+1; j-last<=d && j<=n; ++j) { if(a[j]<=a[i]){ last = j; } else { ret = max(ret, solve(j)); } } ret++; return ret; } int main(){ cin>>n>>d; for(int i=1; i<=n; ++i) { cin>>a[i]; } memset(dp, -1, sizeof dp); int ans = 0; for(int i=1; i<=n; ++i) { ans = max(ans, solve(i)); } cout<<ans; }
#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...