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;
#define ll long long
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n, k; cin >> n >> k;
vector<int> v(n), a(n);
vector<pair<int,int>> b(n);
for (int i = 0; i < n; ++i) {
cin >> v[i];
b[i] = {v[i], i};
}
sort(b.begin(), b.end());
int team = 0;
for (int i = 0; i < n; ++i) {
if (i % k == 0) team++;
a[b[i].second] = team;
}
//for (int i = 0; i < n; ++i) {
//cout << a[i] << " ";
//}
//cout << endl;
vector<int> lis;
for (int i = 0; i < n; ++i) {
auto it = upper_bound(lis.begin(), lis.end(), a[i]);
if (it != lis.end()) *it = a[i];
else lis.push_back(a[i]);
}
//cout << lis.size() << "\n";
cout << n - lis.size() << "\n";
return 0;
}
# | 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... |