Submission #503422

#TimeUsernameProblemLanguageResultExecution timeMemory
503422DanerZeinFinancial Report (JOI21_financial)C++14
0 / 100
4081 ms88896 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; int n,d; map<ii,int> dp; int report(int id,ll ma){ if(dp.find(ii(id,ma))!=dp.end()) return dp[ii(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,x[i]); bool sw=(x[i]>ma); ans=max(ans,report(i,nma)+sw); } return dp[ii(id,ma)]=ans; } int main(){ cin>>n>>d; x.push_back(0); for(int i=0;i<n;i++){ ll a; cin>>a; x.push_back(a); } cout<<report(0,0)<<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...