# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
88773 | arman_ferdous | Studentsko (COCI14_studentsko) | C++17 | 6 ms | 1236 KiB |
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 n, k;
vector<int> arr, v;
map<int,int> id;
int lis() {
vector<int> tmp;
for(int i = 0; i < n; i++) {
vector<int>::iterator it = upper_bound(tmp.begin(), tmp.end(), v[i]);
if(it == tmp.end()) tmp.push_back(v[i]);
else tmp[it - tmp.begin()] = v[i];
} return tmp.size();
}
int main() {
scanf("%d %d", &n, &k);
for(int i = 0; i < n; i++) {
int x; scanf("%d", &x);
arr.push_back(x);
} v = arr;
sort(v.begin(), v.end());
for(int i = 0; i < n; i++)
id[v[i]] = i/k;
for(int i = 0; i < n; i++)
v[i] = id[arr[i]];
// for(int x : v) cerr << x << " "; cerr << endl;
// cerr << "lis = " << lis() << endl;
int ans = n - lis();
printf("%d\n", ans);
return 0;
}
Compilation message (stderr)
# | 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... |