#include <bits/stdc++.h>
using namespace std;
const long long Nmax = 2e5 + 5;
long long n, a[Nmax], m, b[Nmax], bit[Nmax];
void update(long long x, long long val)
{
for (; x < Nmax; x += x & -x)
{
bit[x] = max(bit[x], val);
}
}
long long gett(long long x)
{
long long res = 0;
for (; x > 0; x -= x & -x)
{
res = max(res, bit[x]);
}
return res;
}
int main()
{
cin >> n >> m;
for (long long i = 1; i <= n; ++i)
{
cin >> a[i];
}
long long nb = 0;
vector <long long> q;
for (long long i = 1; i <= n; ++i)
{
if (a[i] > m * i) continue;
b[++nb] = i * m - a[i];
q.push_back(b[nb]);
}
sort(q.begin(), q.end());
for (long long i = 1; i <= nb; ++i)
{
b[i] = lower_bound(q.begin(), q.end(), b[i]) - q.begin() + 1;
}
long long res = 0;
for (long long i = 1; i <= nb; ++i)
{
long long t = gett(b[i]) + 1;
update(b[i], t);
res = max(res, t);
}
cout << n - res;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
332 KB |
Output is correct |
11 |
Correct |
0 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
332 KB |
Output is correct |
13 |
Correct |
0 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
0 ms |
336 KB |
Output is correct |
16 |
Correct |
0 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
332 KB |
Output is correct |
11 |
Correct |
0 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
332 KB |
Output is correct |
13 |
Correct |
0 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
0 ms |
336 KB |
Output is correct |
16 |
Correct |
0 ms |
336 KB |
Output is correct |
17 |
Correct |
0 ms |
336 KB |
Output is correct |
18 |
Correct |
0 ms |
208 KB |
Output is correct |
19 |
Correct |
0 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
464 KB |
Output is correct |
21 |
Correct |
1 ms |
568 KB |
Output is correct |
22 |
Correct |
2 ms |
336 KB |
Output is correct |
23 |
Correct |
3 ms |
464 KB |
Output is correct |
24 |
Correct |
2 ms |
476 KB |
Output is correct |
25 |
Correct |
2 ms |
464 KB |
Output is correct |
26 |
Correct |
2 ms |
592 KB |
Output is correct |
27 |
Correct |
2 ms |
464 KB |
Output is correct |
28 |
Correct |
2 ms |
464 KB |
Output is correct |
29 |
Correct |
2 ms |
464 KB |
Output is correct |
30 |
Correct |
2 ms |
464 KB |
Output is correct |
31 |
Correct |
2 ms |
464 KB |
Output is correct |
32 |
Correct |
2 ms |
476 KB |
Output is correct |
33 |
Correct |
2 ms |
464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
464 KB |
Output is correct |
5 |
Correct |
1 ms |
568 KB |
Output is correct |
6 |
Correct |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
3 ms |
464 KB |
Output is correct |
8 |
Correct |
2 ms |
476 KB |
Output is correct |
9 |
Correct |
2 ms |
464 KB |
Output is correct |
10 |
Correct |
2 ms |
592 KB |
Output is correct |
11 |
Correct |
2 ms |
464 KB |
Output is correct |
12 |
Correct |
2 ms |
464 KB |
Output is correct |
13 |
Correct |
2 ms |
464 KB |
Output is correct |
14 |
Correct |
2 ms |
464 KB |
Output is correct |
15 |
Correct |
2 ms |
464 KB |
Output is correct |
16 |
Correct |
2 ms |
476 KB |
Output is correct |
17 |
Correct |
2 ms |
464 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
304 KB |
Output is correct |
20 |
Correct |
0 ms |
332 KB |
Output is correct |
21 |
Correct |
0 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
304 KB |
Output is correct |
23 |
Correct |
0 ms |
332 KB |
Output is correct |
24 |
Correct |
0 ms |
204 KB |
Output is correct |
25 |
Correct |
0 ms |
332 KB |
Output is correct |
26 |
Correct |
0 ms |
332 KB |
Output is correct |
27 |
Correct |
0 ms |
332 KB |
Output is correct |
28 |
Correct |
0 ms |
332 KB |
Output is correct |
29 |
Correct |
0 ms |
332 KB |
Output is correct |
30 |
Correct |
0 ms |
336 KB |
Output is correct |
31 |
Correct |
1 ms |
336 KB |
Output is correct |
32 |
Correct |
0 ms |
336 KB |
Output is correct |
33 |
Correct |
0 ms |
336 KB |
Output is correct |
34 |
Correct |
2 ms |
336 KB |
Output is correct |
35 |
Correct |
2 ms |
440 KB |
Output is correct |
36 |
Correct |
2 ms |
372 KB |
Output is correct |
37 |
Correct |
3 ms |
592 KB |
Output is correct |
38 |
Correct |
3 ms |
444 KB |
Output is correct |
39 |
Correct |
3 ms |
568 KB |
Output is correct |
40 |
Correct |
2 ms |
464 KB |
Output is correct |
41 |
Correct |
1 ms |
336 KB |
Output is correct |
42 |
Correct |
2 ms |
484 KB |
Output is correct |
43 |
Correct |
2 ms |
592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
336 KB |
Output is correct |
2 |
Correct |
2 ms |
440 KB |
Output is correct |
3 |
Correct |
2 ms |
372 KB |
Output is correct |
4 |
Correct |
3 ms |
592 KB |
Output is correct |
5 |
Correct |
3 ms |
444 KB |
Output is correct |
6 |
Correct |
3 ms |
568 KB |
Output is correct |
7 |
Correct |
2 ms |
464 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
2 ms |
484 KB |
Output is correct |
10 |
Correct |
2 ms |
592 KB |
Output is correct |
11 |
Correct |
0 ms |
336 KB |
Output is correct |
12 |
Correct |
0 ms |
208 KB |
Output is correct |
13 |
Correct |
0 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
464 KB |
Output is correct |
15 |
Correct |
1 ms |
568 KB |
Output is correct |
16 |
Correct |
2 ms |
336 KB |
Output is correct |
17 |
Correct |
3 ms |
464 KB |
Output is correct |
18 |
Correct |
2 ms |
476 KB |
Output is correct |
19 |
Correct |
2 ms |
464 KB |
Output is correct |
20 |
Correct |
2 ms |
592 KB |
Output is correct |
21 |
Correct |
2 ms |
464 KB |
Output is correct |
22 |
Correct |
2 ms |
464 KB |
Output is correct |
23 |
Correct |
2 ms |
464 KB |
Output is correct |
24 |
Correct |
2 ms |
464 KB |
Output is correct |
25 |
Correct |
2 ms |
464 KB |
Output is correct |
26 |
Correct |
2 ms |
476 KB |
Output is correct |
27 |
Correct |
2 ms |
464 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
304 KB |
Output is correct |
30 |
Correct |
0 ms |
332 KB |
Output is correct |
31 |
Correct |
0 ms |
332 KB |
Output is correct |
32 |
Correct |
1 ms |
304 KB |
Output is correct |
33 |
Correct |
0 ms |
332 KB |
Output is correct |
34 |
Correct |
0 ms |
204 KB |
Output is correct |
35 |
Correct |
0 ms |
332 KB |
Output is correct |
36 |
Correct |
0 ms |
332 KB |
Output is correct |
37 |
Correct |
0 ms |
332 KB |
Output is correct |
38 |
Correct |
0 ms |
332 KB |
Output is correct |
39 |
Correct |
0 ms |
332 KB |
Output is correct |
40 |
Correct |
0 ms |
336 KB |
Output is correct |
41 |
Correct |
1 ms |
336 KB |
Output is correct |
42 |
Correct |
0 ms |
336 KB |
Output is correct |
43 |
Correct |
0 ms |
336 KB |
Output is correct |
44 |
Correct |
54 ms |
7024 KB |
Output is correct |
45 |
Correct |
74 ms |
3780 KB |
Output is correct |
46 |
Correct |
95 ms |
6272 KB |
Output is correct |
47 |
Correct |
96 ms |
6224 KB |
Output is correct |
48 |
Correct |
67 ms |
7492 KB |
Output is correct |
49 |
Correct |
72 ms |
7724 KB |
Output is correct |
50 |
Correct |
84 ms |
6920 KB |
Output is correct |
51 |
Correct |
90 ms |
7008 KB |
Output is correct |
52 |
Correct |
68 ms |
6752 KB |
Output is correct |
53 |
Correct |
53 ms |
3104 KB |
Output is correct |
54 |
Correct |
71 ms |
7728 KB |
Output is correct |
55 |
Correct |
69 ms |
7732 KB |
Output is correct |