답안 #550771

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
550771 2022-04-19T07:04:12 Z _karan_gandhi Rabbit Carrot (LMIO19_triusis) C++17
63 / 100
1000 ms 2276 KB
#include <bits/stdc++.h>
using namespace std;

#define all(v) v.begin(), v.end()
#define endl '\n'
#define pl(var) " [" << #var << ": " << (var) << "] "
#define ll long long

void solve() {
	// get the longest sequence satisfying this

	int n, h; cin >> n >> h;

	vector<int> arr(n + 1); 
	for (int i = 1; i <= n; i++) cin >> arr[i];

	vector<int> dp(n + 1, 0);
	dp[0] = 0;
	for (int i = 1; i <= n; i++) {
		// dp[i] = 1;
		// cout << pl(i) << endl;
		if (i * h >= arr[i]) {
			dp[i] = 1;
		} else {
			continue;
		}
		for (int j = i - 1; j >= 1; j--) {
			// cout << pl(j) << pl(dp[j]) << pl(arr[j]) << endl;
			if (arr[j] >= arr[i]) {
				dp[i] = max(dp[i], dp[j] + 1);
			} else if (arr[j] + (i - j) * h >= arr[i]) {
				dp[i] = max(dp[i], dp[j] + 1);
			}
		}
		// cout << pl(dp[i]) << endl;
	}

	int ans = 0;

	for (int i = 0; i <= n; i++) ans = max(ans, dp[i]);

	cout << (n - ans) << endl;
}

int main() {
	// freopen(".in", "r", stdin);
	// freopen(".out", "w", stdout);

	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int T = 1;
	// cin >> T;
	while (T--)
		solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 29 ms 324 KB Output is correct
21 Correct 44 ms 340 KB Output is correct
22 Correct 1 ms 360 KB Output is correct
23 Correct 51 ms 328 KB Output is correct
24 Correct 54 ms 340 KB Output is correct
25 Correct 48 ms 340 KB Output is correct
26 Correct 48 ms 360 KB Output is correct
27 Correct 29 ms 340 KB Output is correct
28 Correct 45 ms 368 KB Output is correct
29 Correct 47 ms 340 KB Output is correct
30 Correct 48 ms 456 KB Output is correct
31 Correct 29 ms 372 KB Output is correct
32 Correct 47 ms 364 KB Output is correct
33 Correct 48 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 29 ms 324 KB Output is correct
5 Correct 44 ms 340 KB Output is correct
6 Correct 1 ms 360 KB Output is correct
7 Correct 51 ms 328 KB Output is correct
8 Correct 54 ms 340 KB Output is correct
9 Correct 48 ms 340 KB Output is correct
10 Correct 48 ms 360 KB Output is correct
11 Correct 29 ms 340 KB Output is correct
12 Correct 45 ms 368 KB Output is correct
13 Correct 47 ms 340 KB Output is correct
14 Correct 48 ms 456 KB Output is correct
15 Correct 29 ms 372 KB Output is correct
16 Correct 47 ms 364 KB Output is correct
17 Correct 48 ms 364 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 316 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 320 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 392 KB Output is correct
35 Correct 2 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
37 Correct 52 ms 368 KB Output is correct
38 Correct 35 ms 388 KB Output is correct
39 Correct 50 ms 340 KB Output is correct
40 Correct 27 ms 340 KB Output is correct
41 Correct 1 ms 364 KB Output is correct
42 Correct 47 ms 340 KB Output is correct
43 Correct 51 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 392 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 52 ms 368 KB Output is correct
5 Correct 35 ms 388 KB Output is correct
6 Correct 50 ms 340 KB Output is correct
7 Correct 27 ms 340 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 47 ms 340 KB Output is correct
10 Correct 51 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 29 ms 324 KB Output is correct
15 Correct 44 ms 340 KB Output is correct
16 Correct 1 ms 360 KB Output is correct
17 Correct 51 ms 328 KB Output is correct
18 Correct 54 ms 340 KB Output is correct
19 Correct 48 ms 340 KB Output is correct
20 Correct 48 ms 360 KB Output is correct
21 Correct 29 ms 340 KB Output is correct
22 Correct 45 ms 368 KB Output is correct
23 Correct 47 ms 340 KB Output is correct
24 Correct 48 ms 456 KB Output is correct
25 Correct 29 ms 372 KB Output is correct
26 Correct 47 ms 364 KB Output is correct
27 Correct 48 ms 364 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 320 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 316 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 320 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Execution timed out 1076 ms 2276 KB Time limit exceeded
45 Halted 0 ms 0 KB -