# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
255861 | shrek12357 | Studentsko (COCI14_studentsko) | C++14 | 54 ms | 760 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 <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
vector<int> nums(n);
vector<pair<int, int>> order(n);
map<int, int> groups;
for (int i = 0; i < n; i++) {
int temp;
cin >> temp;
nums[i] = temp;
order[i].first = temp;
}
sort(nums.begin(), nums.end());
for (int i = 0; i < n; i++) {
groups[nums[i]] = (i / k + 1);
}
for (int i = 0; i < n; i++) {
order[i].second = groups[order[i].first];
}
int smallest = 0;
vector<int> ans(n);
ans[0] = 1;
for (int i = 1; i < n; i++) {
ans[i] = 1;
for (int j = 0; j < i; j++) {
if (order[i].second >= order[j].second && ans[i] < ans[j] + 1) {
ans[i] = ans[j] + 1;
}
}
}
int best = 0;
for (int i = 0; i < n; i++) {
best = max(best, ans[i]);
}
cout << n - best << endl;
}
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... |