제출 #596667

#제출 시각아이디문제언어결과실행 시간메모리
596667DanerZeinFinancial Report (JOI21_financial)C++14
0 / 100
361 ms398756 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,ll> ii; const int MAX_N=3e5+10; vector<ll> x; ll val[7010]; int n,d; int dp[7010][7010]; int report(int id,ll ma){ if(dp[id][ma]!=-1) return dp[id][ma]; if(id==n) return 0; int r; if(id==0) r=n; else r=min(n,id+d); int ans=0; for(int i=id+1;i<=r;i++){ ll nma=max(ma,val[i]); bool sw=(val[i]>ma); ans=max(ans,report(i,nma)+sw); } return dp[id][ma]=ans; } int main(){ memset(dp,-1,sizeof dp); cin>>n>>d; x.push_back(-1); set<int> comp; for(int i=0;i<n;i++){ ll a; cin>>a; comp.insert(a); x.push_back(a); } map<int,int> m; int c=0; for(auto &v:comp){ m[v]=c; c++; } for(int i=1;i<=n;i++){ val[i]=m[x[i]]; } cout<<report(0,-1)<<endl; }
#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...