#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pr pair<int, int>
#define prr pair<pr, int>
#define f first
#define s second
#define pr pair<int, int>
#define pb push_back
const int ndim=2e5+1;
vector<int> par(ndim);
vector<int> psize(ndim);
int main(){
int n, m; cin>>n>>m;
vector<int> a(n), d;
for (int i=0; i<n; i++) cin>>a[i];
for (int i=0; i<n; i++) {
if(m*(i+1)-a[i]>=0) d.pb(m*(i+1)-a[i]);
}
//for (auto e: d) cout<<e<<" ";
//cout<<endl;
vector<int> st;
for (int i=0; i<(int)d.size(); i++){
if(i==0) {st.pb(d[i]); continue; }
auto it=upper_bound(st.begin(), st.end(), d[i]);
int pos=upper_bound(st.begin(), st.end(), d[i])-st.begin();
if(it==st.end()) st.pb(d[i]);
else{
st[pos]=d[i];
}
//for (auto e: st) cout<<e<<" ";
//cout<<endl;
}
cout<<n-st.size()<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1884 KB |
Output is correct |
2 |
Correct |
1 ms |
2024 KB |
Output is correct |
3 |
Correct |
1 ms |
1884 KB |
Output is correct |
4 |
Correct |
1 ms |
1884 KB |
Output is correct |
5 |
Correct |
1 ms |
1884 KB |
Output is correct |
6 |
Correct |
1 ms |
2016 KB |
Output is correct |
7 |
Correct |
1 ms |
1884 KB |
Output is correct |
8 |
Correct |
1 ms |
2020 KB |
Output is correct |
9 |
Correct |
1 ms |
1884 KB |
Output is correct |
10 |
Correct |
1 ms |
1884 KB |
Output is correct |
11 |
Correct |
1 ms |
1884 KB |
Output is correct |
12 |
Correct |
1 ms |
1884 KB |
Output is correct |
13 |
Correct |
1 ms |
1884 KB |
Output is correct |
14 |
Correct |
1 ms |
1884 KB |
Output is correct |
15 |
Correct |
1 ms |
1884 KB |
Output is correct |
16 |
Correct |
1 ms |
1884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1884 KB |
Output is correct |
2 |
Correct |
1 ms |
2024 KB |
Output is correct |
3 |
Correct |
1 ms |
1884 KB |
Output is correct |
4 |
Correct |
1 ms |
1884 KB |
Output is correct |
5 |
Correct |
1 ms |
1884 KB |
Output is correct |
6 |
Correct |
1 ms |
2016 KB |
Output is correct |
7 |
Correct |
1 ms |
1884 KB |
Output is correct |
8 |
Correct |
1 ms |
2020 KB |
Output is correct |
9 |
Correct |
1 ms |
1884 KB |
Output is correct |
10 |
Correct |
1 ms |
1884 KB |
Output is correct |
11 |
Correct |
1 ms |
1884 KB |
Output is correct |
12 |
Correct |
1 ms |
1884 KB |
Output is correct |
13 |
Correct |
1 ms |
1884 KB |
Output is correct |
14 |
Correct |
1 ms |
1884 KB |
Output is correct |
15 |
Correct |
1 ms |
1884 KB |
Output is correct |
16 |
Correct |
1 ms |
1884 KB |
Output is correct |
17 |
Correct |
1 ms |
1884 KB |
Output is correct |
18 |
Correct |
1 ms |
1884 KB |
Output is correct |
19 |
Correct |
1 ms |
1884 KB |
Output is correct |
20 |
Correct |
1 ms |
1884 KB |
Output is correct |
21 |
Correct |
2 ms |
2096 KB |
Output is correct |
22 |
Correct |
2 ms |
1884 KB |
Output is correct |
23 |
Correct |
2 ms |
1880 KB |
Output is correct |
24 |
Correct |
2 ms |
2136 KB |
Output is correct |
25 |
Correct |
2 ms |
1884 KB |
Output is correct |
26 |
Correct |
2 ms |
2036 KB |
Output is correct |
27 |
Correct |
2 ms |
1884 KB |
Output is correct |
28 |
Correct |
2 ms |
2136 KB |
Output is correct |
29 |
Correct |
2 ms |
2048 KB |
Output is correct |
30 |
Correct |
2 ms |
2140 KB |
Output is correct |
31 |
Correct |
2 ms |
1884 KB |
Output is correct |
32 |
Correct |
2 ms |
1884 KB |
Output is correct |
33 |
Correct |
2 ms |
1884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1884 KB |
Output is correct |
2 |
Correct |
1 ms |
1884 KB |
Output is correct |
3 |
Correct |
1 ms |
1884 KB |
Output is correct |
4 |
Correct |
1 ms |
1884 KB |
Output is correct |
5 |
Correct |
2 ms |
2096 KB |
Output is correct |
6 |
Correct |
2 ms |
1884 KB |
Output is correct |
7 |
Correct |
2 ms |
1880 KB |
Output is correct |
8 |
Correct |
2 ms |
2136 KB |
Output is correct |
9 |
Correct |
2 ms |
1884 KB |
Output is correct |
10 |
Correct |
2 ms |
2036 KB |
Output is correct |
11 |
Correct |
2 ms |
1884 KB |
Output is correct |
12 |
Correct |
2 ms |
2136 KB |
Output is correct |
13 |
Correct |
2 ms |
2048 KB |
Output is correct |
14 |
Correct |
2 ms |
2140 KB |
Output is correct |
15 |
Correct |
2 ms |
1884 KB |
Output is correct |
16 |
Correct |
2 ms |
1884 KB |
Output is correct |
17 |
Correct |
2 ms |
1884 KB |
Output is correct |
18 |
Correct |
1 ms |
1884 KB |
Output is correct |
19 |
Correct |
1 ms |
2024 KB |
Output is correct |
20 |
Correct |
1 ms |
1884 KB |
Output is correct |
21 |
Correct |
1 ms |
1884 KB |
Output is correct |
22 |
Correct |
1 ms |
1884 KB |
Output is correct |
23 |
Correct |
1 ms |
2016 KB |
Output is correct |
24 |
Correct |
1 ms |
1884 KB |
Output is correct |
25 |
Correct |
1 ms |
2020 KB |
Output is correct |
26 |
Correct |
1 ms |
1884 KB |
Output is correct |
27 |
Correct |
1 ms |
1884 KB |
Output is correct |
28 |
Correct |
1 ms |
1884 KB |
Output is correct |
29 |
Correct |
1 ms |
1884 KB |
Output is correct |
30 |
Correct |
1 ms |
1884 KB |
Output is correct |
31 |
Correct |
1 ms |
1884 KB |
Output is correct |
32 |
Correct |
1 ms |
1884 KB |
Output is correct |
33 |
Correct |
1 ms |
1884 KB |
Output is correct |
34 |
Correct |
2 ms |
1880 KB |
Output is correct |
35 |
Correct |
2 ms |
1884 KB |
Output is correct |
36 |
Correct |
2 ms |
1884 KB |
Output is correct |
37 |
Correct |
2 ms |
2140 KB |
Output is correct |
38 |
Correct |
2 ms |
1884 KB |
Output is correct |
39 |
Correct |
3 ms |
2136 KB |
Output is correct |
40 |
Correct |
2 ms |
1884 KB |
Output is correct |
41 |
Correct |
1 ms |
1884 KB |
Output is correct |
42 |
Correct |
2 ms |
1884 KB |
Output is correct |
43 |
Correct |
2 ms |
1880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1880 KB |
Output is correct |
2 |
Correct |
2 ms |
1884 KB |
Output is correct |
3 |
Correct |
2 ms |
1884 KB |
Output is correct |
4 |
Correct |
2 ms |
2140 KB |
Output is correct |
5 |
Correct |
2 ms |
1884 KB |
Output is correct |
6 |
Correct |
3 ms |
2136 KB |
Output is correct |
7 |
Correct |
2 ms |
1884 KB |
Output is correct |
8 |
Correct |
1 ms |
1884 KB |
Output is correct |
9 |
Correct |
2 ms |
1884 KB |
Output is correct |
10 |
Correct |
2 ms |
1880 KB |
Output is correct |
11 |
Correct |
1 ms |
1884 KB |
Output is correct |
12 |
Correct |
1 ms |
1884 KB |
Output is correct |
13 |
Correct |
1 ms |
1884 KB |
Output is correct |
14 |
Correct |
1 ms |
1884 KB |
Output is correct |
15 |
Correct |
2 ms |
2096 KB |
Output is correct |
16 |
Correct |
2 ms |
1884 KB |
Output is correct |
17 |
Correct |
2 ms |
1880 KB |
Output is correct |
18 |
Correct |
2 ms |
2136 KB |
Output is correct |
19 |
Correct |
2 ms |
1884 KB |
Output is correct |
20 |
Correct |
2 ms |
2036 KB |
Output is correct |
21 |
Correct |
2 ms |
1884 KB |
Output is correct |
22 |
Correct |
2 ms |
2136 KB |
Output is correct |
23 |
Correct |
2 ms |
2048 KB |
Output is correct |
24 |
Correct |
2 ms |
2140 KB |
Output is correct |
25 |
Correct |
2 ms |
1884 KB |
Output is correct |
26 |
Correct |
2 ms |
1884 KB |
Output is correct |
27 |
Correct |
2 ms |
1884 KB |
Output is correct |
28 |
Correct |
1 ms |
1884 KB |
Output is correct |
29 |
Correct |
1 ms |
2024 KB |
Output is correct |
30 |
Correct |
1 ms |
1884 KB |
Output is correct |
31 |
Correct |
1 ms |
1884 KB |
Output is correct |
32 |
Correct |
1 ms |
1884 KB |
Output is correct |
33 |
Correct |
1 ms |
2016 KB |
Output is correct |
34 |
Correct |
1 ms |
1884 KB |
Output is correct |
35 |
Correct |
1 ms |
2020 KB |
Output is correct |
36 |
Correct |
1 ms |
1884 KB |
Output is correct |
37 |
Correct |
1 ms |
1884 KB |
Output is correct |
38 |
Correct |
1 ms |
1884 KB |
Output is correct |
39 |
Correct |
1 ms |
1884 KB |
Output is correct |
40 |
Correct |
1 ms |
1884 KB |
Output is correct |
41 |
Correct |
1 ms |
1884 KB |
Output is correct |
42 |
Correct |
1 ms |
1884 KB |
Output is correct |
43 |
Correct |
1 ms |
1884 KB |
Output is correct |
44 |
Correct |
28 ms |
5300 KB |
Output is correct |
45 |
Correct |
53 ms |
4696 KB |
Output is correct |
46 |
Correct |
61 ms |
5204 KB |
Output is correct |
47 |
Correct |
55 ms |
5196 KB |
Output is correct |
48 |
Correct |
37 ms |
5828 KB |
Output is correct |
49 |
Correct |
38 ms |
6088 KB |
Output is correct |
50 |
Correct |
57 ms |
6128 KB |
Output is correct |
51 |
Correct |
54 ms |
6856 KB |
Output is correct |
52 |
Correct |
36 ms |
5320 KB |
Output is correct |
53 |
Correct |
39 ms |
3920 KB |
Output is correct |
54 |
Correct |
38 ms |
6032 KB |
Output is correct |
55 |
Correct |
38 ms |
6084 KB |
Output is correct |