Submission #715590

# Submission time Handle Problem Language Result Execution time Memory
715590 2023-03-27T09:18:55 Z amunduzbaev Rabbit Carrot (LMIO19_triusis) C++17
100 / 100
170 ms 13320 KB
#include "bits/stdc++.h"
using namespace std;

#define ar array
typedef long long ll;
#define int ll

const int N = 2e5 + 5;
int a[N], dp[N];

struct ST{
	int tree[N << 2];
	ST(){
		memset(tree, 200, sizeof tree);
	}
	
	void set(int i, int v, int lx = 0, int rx = N, int x = 1){
		if(lx == rx) { tree[x] = max(tree[x], v); return; }
		int m = (lx + rx) >> 1;
		if(i <= m) set(i, v, lx, m, x << 1);
		else set(i, v, m + 1, rx, x << 1 | 1);
		tree[x] = max(tree[x << 1], tree[x << 1 | 1]);
	}
	
	int get(int l, int r, int lx = 0, int rx = N, int x = 1){
		if(lx > r || rx < l) return -N;
		if(lx >= l && rx <= r) return tree[x];
		int m = (lx + rx) >> 1;
		return max(get(l, r, lx, m, x << 1), get(l, r, m + 1, rx, x << 1 | 1));
	}
}tree;

signed main(){
	ios::sync_with_stdio(0); cin.tie(0);

	int n, m; cin >> n >> m;
	vector<int> t;
	t.push_back(0);
	for(int i=1;i<=n;i++){
		cin >> a[i];
		a[i] -= i * m;
		t.push_back(a[i]);
	}
	sort(t.begin(), t.end());
	t.erase(unique(t.begin(), t.end()), t.end());
	{
		int j = lower_bound(t.begin(), t.end(), a[0]) - t.begin();
		tree.set(j, 0);
	}
	for(int i=1;i<=n;i++){
		int j = lower_bound(t.begin(), t.end(), a[i]) - t.begin();
		dp[i] = tree.get(j, n) + 1;
		tree.set(j, dp[i]);
	}
	
	cout<<n - tree.get(0, n)<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6484 KB Output is correct
2 Correct 3 ms 6484 KB Output is correct
3 Correct 3 ms 6588 KB Output is correct
4 Correct 4 ms 6592 KB Output is correct
5 Correct 5 ms 6484 KB Output is correct
6 Correct 3 ms 6588 KB Output is correct
7 Correct 3 ms 6484 KB Output is correct
8 Correct 4 ms 6484 KB Output is correct
9 Correct 3 ms 6588 KB Output is correct
10 Correct 3 ms 6588 KB Output is correct
11 Correct 3 ms 6588 KB Output is correct
12 Correct 3 ms 6484 KB Output is correct
13 Correct 3 ms 6584 KB Output is correct
14 Correct 4 ms 6484 KB Output is correct
15 Correct 3 ms 6580 KB Output is correct
16 Correct 4 ms 6484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6484 KB Output is correct
2 Correct 3 ms 6484 KB Output is correct
3 Correct 3 ms 6588 KB Output is correct
4 Correct 4 ms 6592 KB Output is correct
5 Correct 5 ms 6484 KB Output is correct
6 Correct 3 ms 6588 KB Output is correct
7 Correct 3 ms 6484 KB Output is correct
8 Correct 4 ms 6484 KB Output is correct
9 Correct 3 ms 6588 KB Output is correct
10 Correct 3 ms 6588 KB Output is correct
11 Correct 3 ms 6588 KB Output is correct
12 Correct 3 ms 6484 KB Output is correct
13 Correct 3 ms 6584 KB Output is correct
14 Correct 4 ms 6484 KB Output is correct
15 Correct 3 ms 6580 KB Output is correct
16 Correct 4 ms 6484 KB Output is correct
17 Correct 4 ms 6588 KB Output is correct
18 Correct 3 ms 6484 KB Output is correct
19 Correct 4 ms 6484 KB Output is correct
20 Correct 5 ms 6612 KB Output is correct
21 Correct 7 ms 6676 KB Output is correct
22 Correct 7 ms 6724 KB Output is correct
23 Correct 6 ms 6720 KB Output is correct
24 Correct 5 ms 6740 KB Output is correct
25 Correct 5 ms 6796 KB Output is correct
26 Correct 5 ms 6740 KB Output is correct
27 Correct 4 ms 6868 KB Output is correct
28 Correct 4 ms 6740 KB Output is correct
29 Correct 6 ms 6740 KB Output is correct
30 Correct 6 ms 6732 KB Output is correct
31 Correct 5 ms 6740 KB Output is correct
32 Correct 7 ms 6740 KB Output is correct
33 Correct 6 ms 6800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6588 KB Output is correct
2 Correct 3 ms 6484 KB Output is correct
3 Correct 4 ms 6484 KB Output is correct
4 Correct 5 ms 6612 KB Output is correct
5 Correct 7 ms 6676 KB Output is correct
6 Correct 7 ms 6724 KB Output is correct
7 Correct 6 ms 6720 KB Output is correct
8 Correct 5 ms 6740 KB Output is correct
9 Correct 5 ms 6796 KB Output is correct
10 Correct 5 ms 6740 KB Output is correct
11 Correct 4 ms 6868 KB Output is correct
12 Correct 4 ms 6740 KB Output is correct
13 Correct 6 ms 6740 KB Output is correct
14 Correct 6 ms 6732 KB Output is correct
15 Correct 5 ms 6740 KB Output is correct
16 Correct 7 ms 6740 KB Output is correct
17 Correct 6 ms 6800 KB Output is correct
18 Correct 4 ms 6484 KB Output is correct
19 Correct 3 ms 6484 KB Output is correct
20 Correct 3 ms 6588 KB Output is correct
21 Correct 4 ms 6592 KB Output is correct
22 Correct 5 ms 6484 KB Output is correct
23 Correct 3 ms 6588 KB Output is correct
24 Correct 3 ms 6484 KB Output is correct
25 Correct 4 ms 6484 KB Output is correct
26 Correct 3 ms 6588 KB Output is correct
27 Correct 3 ms 6588 KB Output is correct
28 Correct 3 ms 6588 KB Output is correct
29 Correct 3 ms 6484 KB Output is correct
30 Correct 3 ms 6584 KB Output is correct
31 Correct 4 ms 6484 KB Output is correct
32 Correct 3 ms 6580 KB Output is correct
33 Correct 4 ms 6484 KB Output is correct
34 Correct 6 ms 6796 KB Output is correct
35 Correct 6 ms 6740 KB Output is correct
36 Correct 7 ms 6740 KB Output is correct
37 Correct 5 ms 6740 KB Output is correct
38 Correct 6 ms 6740 KB Output is correct
39 Correct 4 ms 6740 KB Output is correct
40 Correct 4 ms 6740 KB Output is correct
41 Correct 4 ms 6732 KB Output is correct
42 Correct 5 ms 6732 KB Output is correct
43 Correct 6 ms 6796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 6796 KB Output is correct
2 Correct 6 ms 6740 KB Output is correct
3 Correct 7 ms 6740 KB Output is correct
4 Correct 5 ms 6740 KB Output is correct
5 Correct 6 ms 6740 KB Output is correct
6 Correct 4 ms 6740 KB Output is correct
7 Correct 4 ms 6740 KB Output is correct
8 Correct 4 ms 6732 KB Output is correct
9 Correct 5 ms 6732 KB Output is correct
10 Correct 6 ms 6796 KB Output is correct
11 Correct 4 ms 6588 KB Output is correct
12 Correct 3 ms 6484 KB Output is correct
13 Correct 4 ms 6484 KB Output is correct
14 Correct 5 ms 6612 KB Output is correct
15 Correct 7 ms 6676 KB Output is correct
16 Correct 7 ms 6724 KB Output is correct
17 Correct 6 ms 6720 KB Output is correct
18 Correct 5 ms 6740 KB Output is correct
19 Correct 5 ms 6796 KB Output is correct
20 Correct 5 ms 6740 KB Output is correct
21 Correct 4 ms 6868 KB Output is correct
22 Correct 4 ms 6740 KB Output is correct
23 Correct 6 ms 6740 KB Output is correct
24 Correct 6 ms 6732 KB Output is correct
25 Correct 5 ms 6740 KB Output is correct
26 Correct 7 ms 6740 KB Output is correct
27 Correct 6 ms 6800 KB Output is correct
28 Correct 4 ms 6484 KB Output is correct
29 Correct 3 ms 6484 KB Output is correct
30 Correct 3 ms 6588 KB Output is correct
31 Correct 4 ms 6592 KB Output is correct
32 Correct 5 ms 6484 KB Output is correct
33 Correct 3 ms 6588 KB Output is correct
34 Correct 3 ms 6484 KB Output is correct
35 Correct 4 ms 6484 KB Output is correct
36 Correct 3 ms 6588 KB Output is correct
37 Correct 3 ms 6588 KB Output is correct
38 Correct 3 ms 6588 KB Output is correct
39 Correct 3 ms 6484 KB Output is correct
40 Correct 3 ms 6584 KB Output is correct
41 Correct 4 ms 6484 KB Output is correct
42 Correct 3 ms 6580 KB Output is correct
43 Correct 4 ms 6484 KB Output is correct
44 Correct 94 ms 11788 KB Output is correct
45 Correct 170 ms 13240 KB Output is correct
46 Correct 147 ms 13240 KB Output is correct
47 Correct 151 ms 13248 KB Output is correct
48 Correct 79 ms 12300 KB Output is correct
49 Correct 77 ms 12460 KB Output is correct
50 Correct 66 ms 13300 KB Output is correct
51 Correct 65 ms 13320 KB Output is correct
52 Correct 74 ms 12288 KB Output is correct
53 Correct 63 ms 12552 KB Output is correct
54 Correct 87 ms 12400 KB Output is correct
55 Correct 79 ms 12344 KB Output is correct