#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n,k;
cin >> n >> k;
vector <int> v(n);
vector <int> p;
for(int i = 0; i < n; i++){
cin >> v[i];
p.push_back(v[i]);
}
sort(p.begin(), p.end());
map <int, int> mp;
for(int i = 0; i < n; i++){
mp[p[i]] = i/k;
}
multiset <int> mst;
for(int i = 0; i < n; i++){
int value = mp[v[i]];
mst.insert(value);
auto it = mst.upper_bound(value);
if(it != mst.end()) mst.erase(mst.find(*it));
}
cout << n - mst.size();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
464 KB |
Output is correct |
2 |
Correct |
2 ms |
668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
668 KB |
Output is correct |
2 |
Correct |
2 ms |
668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
948 KB |
Output is correct |
2 |
Correct |
5 ms |
1036 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1060 KB |
Output is correct |
2 |
Correct |
6 ms |
1108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1160 KB |
Output is correct |
2 |
Correct |
5 ms |
1340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1340 KB |
Output is correct |
2 |
Correct |
5 ms |
1352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1400 KB |
Output is correct |
2 |
Correct |
6 ms |
1468 KB |
Output is correct |