Submission #864178

# Submission time Handle Problem Language Result Execution time Memory
864178 2023-10-22T08:06:51 Z vjudge1 Financial Report (JOI21_financial) C++17
0 / 100
8 ms 856 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n, d;
vi arr;
int cnt[7100], can_jump[7100][7100];
int main(){
	cin>>n>>d;
	for(int i = 1; i <= n; i++){
		cin>>cnt[i];
		arr.pb(cnt[i]);
	}
	if(d == n){
		vi rez(n+1, 2e9);
		rez[0] = -2e9;
		for(int i = 0; i < n; i++){
			int l = upper_bound(rez.begin(), rez.end(), cnt[i+1]) - rez.begin();
			if(rez[l-1] < cnt[i+1] && cnt[i+1] < rez[l])
				rez[l] = cnt[i+1];
		}
		int ans = 0;
		for(int i = 0; i < n; i++){
			if(rez[i] < 2e9)	ans =i;
		}
		cout<<ans<<endl;
		return 0;
	}else{
		sort(arr.begin(), arr.end());
		memset(can_jump, 0, sizeof can_jump);
		arr.erase(unique(arr.begin(), arr.end()), arr.end());
		for(int i = 1; i <= n; i++)	cnt[i] = lower_bound(arr.begin(), arr.end(), cnt[i]) - arr.begin() + 1;
		for(int i = 1; i <= n; i++){
			int last = i;
			for(int j = i +1; j <= n; j++){
				if(j - last <= d && cnt[i] < cnt[j])	can_jump[i][j] = 1;
				if(j - last <= d && cnt[i] >= cnt[j])	last = j;
			}
		}
		int dp[n+1];
		for(int i = 1; i <= n; i++){
			dp[i] = 1;
			for(int j = 1; j < i; j++){
				if(!can_jump[j][i])	continue;
				dp[i] = max(dp[i], dp[j] + 1);
			}
		}
		int ans = 0;
		for(int i = 1; i <= n; i++)
			ans = max(ans, dp[i]);
			
		cout<<ans<<endl;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 856 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -