제출 #974727

#제출 시각아이디문제언어결과실행 시간메모리
974727LCJLYFinancial Report (JOI21_financial)C++14
48 / 100
81 ms860 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[7005];
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));
	int best=0;
	for(int x=1;x<=n;x++){
		dp[x]=max(dp[x],1LL);
		int left=k;
		for(int y=x+1;y<=n;y++){
			if(left==0) break;
			if(arr[y]>arr[x]){
				dp[y]=max(dp[y],dp[x]+1);
			}
			else if(arr[y]==arr[x]){
				dp[y]=max(dp[y],dp[x]);
				left=k+1;
			}
			else if(arr[y]<arr[x]) left=k+1;
			left--;
		}
		//show(dp[x],dp[x]);
		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...