This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |