# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1055320 | YassirSalama | Financial Report (JOI21_financial) | C++17 | 4050 ms | 21328 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
const int maxn=3e5+100;
#define all(v) v.begin(),v.end()
signed main(){
int n,d;
cin>>n>>d;
vector<int> v(n);
for(int i=0;i<n;i++){
cin>>v[i];
}
vector<int> c=v;sort(all(c));c.erase(unique(all(c)),c.end());
map<int,int> mp;for(int i=0;i<c.size();i++) mp[c[i]]=i;
int dp[n][c.size()];
memset(dp,0,sizeof(dp));
dp[0][mp[v[0]]]=1;
for(int i=1;i<n;i++){
int t=mp[v[i]];
for(int k=i-1;k>=0&&k>=i-d;k--){
for(int j=0;j<c.size();j++){
if(t>j){
dp[i][t]=max(dp[i][t],dp[k][j]+1);
}else{
dp[i][j]=max(dp[i][j],dp[k][j]);
}
}
}
}
int ans=0;
for(int i=0;i<c.size();i++) ans=max(ans,dp[n-1][i]);
cout<<ans<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |