#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+1;
int a[N],n,m;
vector<int> v;
auto nen_so(vector<int>v)
{
set<int>st;
for(int x:v) st.insert(x);
map<int,int>mp;
int cnt=1;
for(auto x:st) mp[x]=cnt++;
for(int i=0;i<v.size();i++) v[i]=mp[v[i]];
return v;
}
int bit[N];
void update(int u,int val)
{
for(int i=u;i<=N;i+=i&(-i)) bit[i]=max(val,bit[i]);
}
int get(int u)
{
int ans=0;
for(int i=u;i>0;i-=i&(-i)) ans=max(ans,bit[i]);
return ans;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen("test.inp","r",stdin);
// freopen("test.out","w",stdout);
cin >> n >> m;
for(int i=1; i<=n; i++)
{
cin >> a[i];
a[i]=m*i-a[i];
}
for(int i=1;i<=n;i++)
{
if(a[i]>=0) v.push_back(a[i]);
}
auto ds=nen_so(v);
for(int x:ds)
{
update(x,get(x)+1);
}
cout << n-get(n);
}
Compilation message
triusis.cpp: In function 'auto nen_so(std::vector<long long int>)':
triusis.cpp:14:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for(int i=0;i<v.size();i++) v[i]=mp[v[i]];
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
308 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
0 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
336 KB |
Output is correct |
13 |
Correct |
0 ms |
316 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
308 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
0 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
336 KB |
Output is correct |
13 |
Correct |
0 ms |
316 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
328 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
332 KB |
Output is correct |
20 |
Correct |
2 ms |
840 KB |
Output is correct |
21 |
Correct |
2 ms |
976 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
3 ms |
1004 KB |
Output is correct |
24 |
Correct |
3 ms |
972 KB |
Output is correct |
25 |
Correct |
3 ms |
976 KB |
Output is correct |
26 |
Correct |
3 ms |
972 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
464 KB |
Output is correct |
29 |
Correct |
2 ms |
972 KB |
Output is correct |
30 |
Correct |
3 ms |
1012 KB |
Output is correct |
31 |
Correct |
3 ms |
716 KB |
Output is correct |
32 |
Correct |
3 ms |
980 KB |
Output is correct |
33 |
Correct |
3 ms |
984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
840 KB |
Output is correct |
5 |
Correct |
2 ms |
976 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
3 ms |
1004 KB |
Output is correct |
8 |
Correct |
3 ms |
972 KB |
Output is correct |
9 |
Correct |
3 ms |
976 KB |
Output is correct |
10 |
Correct |
3 ms |
972 KB |
Output is correct |
11 |
Correct |
1 ms |
468 KB |
Output is correct |
12 |
Correct |
1 ms |
464 KB |
Output is correct |
13 |
Correct |
2 ms |
972 KB |
Output is correct |
14 |
Correct |
3 ms |
1012 KB |
Output is correct |
15 |
Correct |
3 ms |
716 KB |
Output is correct |
16 |
Correct |
3 ms |
980 KB |
Output is correct |
17 |
Correct |
3 ms |
984 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
332 KB |
Output is correct |
21 |
Correct |
0 ms |
332 KB |
Output is correct |
22 |
Correct |
0 ms |
332 KB |
Output is correct |
23 |
Correct |
1 ms |
308 KB |
Output is correct |
24 |
Correct |
0 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
332 KB |
Output is correct |
26 |
Correct |
0 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
0 ms |
332 KB |
Output is correct |
29 |
Correct |
0 ms |
336 KB |
Output is correct |
30 |
Correct |
0 ms |
316 KB |
Output is correct |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
0 ms |
336 KB |
Output is correct |
33 |
Correct |
1 ms |
332 KB |
Output is correct |
34 |
Correct |
1 ms |
336 KB |
Output is correct |
35 |
Correct |
2 ms |
428 KB |
Output is correct |
36 |
Correct |
1 ms |
460 KB |
Output is correct |
37 |
Correct |
3 ms |
980 KB |
Output is correct |
38 |
Correct |
1 ms |
468 KB |
Output is correct |
39 |
Correct |
1 ms |
464 KB |
Output is correct |
40 |
Correct |
2 ms |
720 KB |
Output is correct |
41 |
Correct |
1 ms |
356 KB |
Output is correct |
42 |
Correct |
3 ms |
976 KB |
Output is correct |
43 |
Correct |
4 ms |
1012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
2 ms |
428 KB |
Output is correct |
3 |
Correct |
1 ms |
460 KB |
Output is correct |
4 |
Correct |
3 ms |
980 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
464 KB |
Output is correct |
7 |
Correct |
2 ms |
720 KB |
Output is correct |
8 |
Correct |
1 ms |
356 KB |
Output is correct |
9 |
Correct |
3 ms |
976 KB |
Output is correct |
10 |
Correct |
4 ms |
1012 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
840 KB |
Output is correct |
15 |
Correct |
2 ms |
976 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
3 ms |
1004 KB |
Output is correct |
18 |
Correct |
3 ms |
972 KB |
Output is correct |
19 |
Correct |
3 ms |
976 KB |
Output is correct |
20 |
Correct |
3 ms |
972 KB |
Output is correct |
21 |
Correct |
1 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
464 KB |
Output is correct |
23 |
Correct |
2 ms |
972 KB |
Output is correct |
24 |
Correct |
3 ms |
1012 KB |
Output is correct |
25 |
Correct |
3 ms |
716 KB |
Output is correct |
26 |
Correct |
3 ms |
980 KB |
Output is correct |
27 |
Correct |
3 ms |
984 KB |
Output is correct |
28 |
Correct |
0 ms |
332 KB |
Output is correct |
29 |
Correct |
0 ms |
204 KB |
Output is correct |
30 |
Correct |
0 ms |
332 KB |
Output is correct |
31 |
Correct |
0 ms |
332 KB |
Output is correct |
32 |
Correct |
0 ms |
332 KB |
Output is correct |
33 |
Correct |
1 ms |
308 KB |
Output is correct |
34 |
Correct |
0 ms |
204 KB |
Output is correct |
35 |
Correct |
1 ms |
332 KB |
Output is correct |
36 |
Correct |
0 ms |
332 KB |
Output is correct |
37 |
Correct |
1 ms |
332 KB |
Output is correct |
38 |
Correct |
0 ms |
332 KB |
Output is correct |
39 |
Correct |
0 ms |
336 KB |
Output is correct |
40 |
Correct |
0 ms |
316 KB |
Output is correct |
41 |
Correct |
0 ms |
344 KB |
Output is correct |
42 |
Correct |
0 ms |
336 KB |
Output is correct |
43 |
Correct |
1 ms |
332 KB |
Output is correct |
44 |
Correct |
130 ms |
28864 KB |
Output is correct |
45 |
Correct |
20 ms |
3788 KB |
Output is correct |
46 |
Correct |
122 ms |
17116 KB |
Output is correct |
47 |
Correct |
104 ms |
17128 KB |
Output is correct |
48 |
Correct |
129 ms |
28860 KB |
Output is correct |
49 |
Correct |
131 ms |
29632 KB |
Output is correct |
50 |
Correct |
35 ms |
6328 KB |
Output is correct |
51 |
Correct |
36 ms |
7020 KB |
Output is correct |
52 |
Correct |
86 ms |
17600 KB |
Output is correct |
53 |
Correct |
18 ms |
3076 KB |
Output is correct |
54 |
Correct |
129 ms |
29308 KB |
Output is correct |
55 |
Correct |
128 ms |
29292 KB |
Output is correct |