# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
201488 | EmmanuelAC | Studentsko (COCI14_studentsko) | C++14 | 24 ms | 632 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> v;
void relabel(vector<int>& mv){
vector<int> aux(n);
for(int i=0; i<n; i++) aux[i] = mv[i];
sort(aux.begin(), aux.end());
map<int, int> idx;
for(int i=0; i<n; i++) idx[aux[i]] = i/k +1;
for(int i=0; i<n; i++) mv[i] = idx[mv[i]];
}
int lis(vector<int>& v){
int sol = 0;
vector<int> lis(n +1);
for(int i=0; i<n; i++){
int mx = 0;
for(int j=0; j<=v[i]; j++)
mx = max(mx, lis[j] );
lis[ v[i] ] = mx +1;
sol = max(sol, lis[v[i]]);
}
return sol;
}
int main(){
scanf("%d %d", &n, &k);
v.resize(n);
for(int i=0; i<n; i++){
int aux; scanf("%d", &aux);
v[i] = aux;
}
relabel(v);
int sol = n - lis(v);
printf("%d\n", sol);
}
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... |