#include<bits/stdc++.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
using namespace std;
// mylittledoge
int main(){
cin.sync_with_stdio(0);
cin.tie(0);
int N, K;
cin >> N >> K;
vector <int> A(N);
map <int, int> M;
for (int i = 0; i < N; i++){
cin >> A[i];
M[A[i]] = 0;
}
int n = 0;
ALL_THE(M,it) it->ss = n++;
for (int i = 0; i < N; i++){
A[i] = M[A[i]] / K;
}
int ansT = 0;
vector <int> ans(N, 1);
for (int i = 0; i < N; i++){
for (int j = 0; j < i; j++){
if (A[j] <= A[i]) ans[i] = max(ans[i], ans[j] + 1);
}
ansT = max(ansT, ans[i]);
}
cout << N - ansT << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
424 KB |
Output is correct |
2 |
Correct |
3 ms |
536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
632 KB |
Output is correct |
2 |
Correct |
2 ms |
812 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
1092 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
52 ms |
1180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
1424 KB |
Output is correct |
2 |
Correct |
47 ms |
1440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
1592 KB |
Output is correct |
2 |
Correct |
51 ms |
1592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
1632 KB |
Output is correct |
2 |
Correct |
35 ms |
1832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
1832 KB |
Output is correct |
2 |
Correct |
49 ms |
1864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
1936 KB |
Output is correct |
2 |
Correct |
51 ms |
1984 KB |
Output is correct |