Submission #738364

#TimeUsernameProblemLanguageResultExecution timeMemory
738364alexddFinancial Report (JOI21_financial)C++17
48 / 100
4059 ms9072 KiB
#include<bits/stdc++.h> using namespace std; int n,d; int a[300005]; int pozs[300005]; int dp[300005]; void calc_pozs() { for(int i=1;i<=n;i++) { int ult=i; pozs[i]=i; for(int j=i-1;j>0;j--) { if(ult-j>d) break; if(a[j]<a[i]) { ult=j; pozs[i]=j; } } } } pair<int,int> ord2[300005]; signed main() { ios_base::sync_with_stdio(0);cin.tie(0); cin>>n>>d; for(int i=1;i<=n;i++) cin>>a[i]; calc_pozs(); for(int i=1;i<=n;i++) { ord2[i]={a[i],-i}; } sort(ord2+1,ord2+1+n); int cur; for(int i=1;i<=n;i++) { cur = -ord2[i].second; for(int j=pozs[cur];j<cur;j++) dp[cur] = max(dp[cur], dp[j]); dp[cur]++; } int rez=1; for(int i=1;i<=n;i++) rez=max(rez,dp[i]); cout<<rez; return 0; }
#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...