Submission #481108

# Submission time Handle Problem Language Result Execution time Memory
481108 2021-10-19T13:39:30 Z s_samchenko Rabbit Carrot (LMIO19_triusis) C++17
63 / 100
1000 ms 3780 KB
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
#define ll long long
#define ff first
#define ss second
#define int ll
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define pii pair <int, int>
using namespace std;
const int inf = 1e15;
const int mod = 1e9+7;
const int N = 3e5+100;

struct segtree{
	int size;
	vector <int> t;
	
	segtree(int n){
		size = 1;
		while (size < n) size <<= 1;
		t.resize(2*size - 1);
	}
	
	void set(int i, int v, int x, int lx, int rx){
		if (rx - lx == 1){
			t[x] = v;
			return;
		}
		int m = (lx + rx) / 2;
		if (i < m) set(i, v, 2*x + 1, lx, m);
		else set(i, v, 2*x + 2, m, rx);
		t[x] = max(t[2*x + 1], t[2*x + 2]);
	}
	
	void set(int i, int v){
		set(i, v, 0, 0, size);
	}
	
	int get(int l, int r, int x, int lx, int rx){
		if (l >= rx || lx >= r) return 0;
		if (l <= lx && r >= rx) return t[x];
		int m = (lx + rx) / 2;
		return max(get(l, r, 2*x + 1, lx, m), get(l, r, 2*x + 2, m, rx));
	}
	
	
	int get(int l, int r){
		return get(l, r + 1, 0, 0, size);
	}
};

void solve(){
	int n, m;
	cin >> n >> m;
	vector <int> a(n+1);
	for (int i = 1; i <= n; ++i) cin >> a[i];
	vector <int> dp(n+1);
	dp[0] = 0;
	for (int i = 1; i <= n; ++i){
		if (a[i] > m * i){
			dp[i] = -inf;
			continue;
		}
		dp[i] = 1;
		for (int j = i - 1; j > 0; --j){
			if (dp[j] == -inf) continue;
			if (a[j] + m * (i - j) >= a[i]) dp[i] = max(dp[i], dp[j] + 1);
		}
	}
	
	cout << n - *max_element(all(dp));
}

signed main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int tt = 1;
	//cin >> tt;
	while (tt--){
		solve();
		cout << '\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 312 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 312 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 32 ms 332 KB Output is correct
21 Correct 49 ms 388 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 51 ms 324 KB Output is correct
24 Correct 49 ms 332 KB Output is correct
25 Correct 48 ms 332 KB Output is correct
26 Correct 49 ms 332 KB Output is correct
27 Correct 38 ms 444 KB Output is correct
28 Correct 49 ms 320 KB Output is correct
29 Correct 50 ms 332 KB Output is correct
30 Correct 53 ms 392 KB Output is correct
31 Correct 32 ms 420 KB Output is correct
32 Correct 48 ms 332 KB Output is correct
33 Correct 48 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 32 ms 332 KB Output is correct
5 Correct 49 ms 388 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 51 ms 324 KB Output is correct
8 Correct 49 ms 332 KB Output is correct
9 Correct 48 ms 332 KB Output is correct
10 Correct 49 ms 332 KB Output is correct
11 Correct 38 ms 444 KB Output is correct
12 Correct 49 ms 320 KB Output is correct
13 Correct 50 ms 332 KB Output is correct
14 Correct 53 ms 392 KB Output is correct
15 Correct 32 ms 420 KB Output is correct
16 Correct 48 ms 332 KB Output is correct
17 Correct 48 ms 332 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 0 ms 312 KB Output is correct
28 Correct 1 ms 312 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 0 ms 204 KB Output is correct
34 Correct 1 ms 368 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 51 ms 328 KB Output is correct
38 Correct 34 ms 332 KB Output is correct
39 Correct 49 ms 416 KB Output is correct
40 Correct 30 ms 460 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 53 ms 332 KB Output is correct
43 Correct 50 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 368 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 51 ms 328 KB Output is correct
5 Correct 34 ms 332 KB Output is correct
6 Correct 49 ms 416 KB Output is correct
7 Correct 30 ms 460 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 53 ms 332 KB Output is correct
10 Correct 50 ms 332 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 32 ms 332 KB Output is correct
15 Correct 49 ms 388 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 51 ms 324 KB Output is correct
18 Correct 49 ms 332 KB Output is correct
19 Correct 48 ms 332 KB Output is correct
20 Correct 49 ms 332 KB Output is correct
21 Correct 38 ms 444 KB Output is correct
22 Correct 49 ms 320 KB Output is correct
23 Correct 50 ms 332 KB Output is correct
24 Correct 53 ms 392 KB Output is correct
25 Correct 32 ms 420 KB Output is correct
26 Correct 48 ms 332 KB Output is correct
27 Correct 48 ms 332 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 0 ms 312 KB Output is correct
38 Correct 1 ms 312 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Execution timed out 1088 ms 3780 KB Time limit exceeded
45 Halted 0 ms 0 KB -