#include <bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio() , cin.tie(0) , cout.tie(0);
int n , k;
cin >> n >> k;
vector<int> a(n);
for(int &x : a)
cin >> x;
vector<int> s(all(a));
sort(all(s));
for(int &x : a)
x = (lower_bound(all(s) , x) - s.begin()) / k + 1;
vector<int> dp(n , 1);
for(int i = 0 ; i < n ; ++i){
for(int j = i + 1 ; j < n ; ++j){
if(a[j] >= a[i])dp[j] = max(dp[j] , dp[i] + 1);
}
}
cout << n - *max_element(all(dp)) << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
504 KB |
Output is correct |
2 |
Correct |
34 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
632 KB |
Output is correct |
2 |
Correct |
42 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
592 KB |
Output is correct |
2 |
Correct |
25 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
516 KB |
Output is correct |
2 |
Correct |
40 ms |
508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
376 KB |
Output is correct |
2 |
Correct |
41 ms |
504 KB |
Output is correct |