Submission #974707

#TimeUsernameProblemLanguageResultExecution timeMemory
974707LCJLYFinancial Report (JOI21_financial)C++14
0 / 100
1 ms604 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ld long double #define show(x,y) cout << y << " " << #x << endl; #define show2(x,y,i,j) cout << y << " " << #x << " " << j << " " << #i << endl; #define show3(x,y,i,j,p,q) cout << y << " " << #x << " " << j << " " << #i << " " << q << " " << #p << endl; #define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl; typedef pair<long long,long long>pii; typedef pair<int,pii>pi2; mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count()); int arr[405]; int n,k; void solve(){ cin >> n >> k; for(int x=1;x<=n;x++){ cin >> arr[x]; } int dp[n+5]; memset(dp,0,sizeof(dp)); dp[n]=1; int best=0; for(int x=n;x>=1;x--){ for(int y=x-1;y>=max(1LL,x-k);y--){ if(arr[x]==arr[y]){ dp[y]=max(dp[y],dp[x]); } else if(arr[x]<arr[y]){ dp[y]=max(dp[y],1LL); } else{ dp[y]=max(dp[y],dp[x]+1); } } best=max(best,dp[x]); } cout << best; } int32_t main(){ ios::sync_with_stdio(0); cin.tie(0); int t=1; //freopen("in.txt","r",stdin); //cin >> t; while(t--){ solve(); } }
#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...