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 pii pair<int, int>
int main() {
int N, K; cin >> N >> K;
vector<pii> a;
vector<int> tb;
for(int i = 0; i < N; i++) {
int x; cin >> x;
a.push_back(pii(x, i));
}
sort(a.begin(), a.end());
vector<int> pos(N);
for(int i = 0; i < N; i++) {
pos[a[i].second] = i / K;
}
int ans = 0;
for(int i = 0; i < N; i++) {
int opt = 0;
for(int j = 0; j < i; j++) if(pos[j] <= pos[i]) opt = max(opt, tb[j]);
tb.push_back(opt + 1);
ans = max(opt+1, ans);
}
cout << N - ans << '\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... |