제출 #1131064

#제출 시각아이디문제언어결과실행 시간메모리
1131064catsarecool5530Rabbit Carrot (LMIO19_triusis)C++20
100 / 100
36 ms3264 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// #define endl "\n";
#define all(x) x.begin(), x.end()
ll MOD = 1e9+7;

void solve() {
	int n, jump; cin >> n >> jump;
	vector<int> a(n+1);
	a[0] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] = -a[i];
	}
	vector<ll> dp{0};
	for (int i = 1; i <= n; i++) {
		ll value = a[i] + jump*i;
		if (value < 0) continue;
		ll index = upper_bound(all(dp), value) - dp.begin();
		if (index == dp.size()) dp.push_back(value);
		else dp[index] = value;
	}
	// for (int i : dp) {
	// 	cout << i << ' ';
	// }
	// cout << endl;
	cout << n - dp.size() + 1 << endl;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	//freopen("example.txt", "r", stdin);
	//freopen("exercise.out", "w", stdout);
	ll t = 1; //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...