#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
int n,k;
int arr[5002],ARR[5002],dp[5002][5002];
map <int,int> indx;
int solve(int i,int j){
if(i==n+1) return 0;
if(dp[i][j]!=-1) return dp[i][j];
if(arr[i]<arr[j]) return dp[i][j]=solve(i+1,j)+1;
else{
return dp[i][j]=min(solve(i+1,i),solve(i+1,j)+1);
}
}
void build1(){
cin>>n>>k;
memset(dp,-1,sizeof dp);
for(int i=1;i<=n;i++){
cin>>arr[i];
ARR[i]=arr[i];
indx[arr[i]]=i;
}
sort(ARR+1,ARR+n+1);
for(int i=1;i<=n;i++) arr[indx[ARR[i]]]=(int)ceil((double)i/k);
return;
}
signed main()
{
build1();
cout<<solve(1,0);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
17 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
16 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
15 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
19 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
67 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
16 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
17 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
16 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
15 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
16 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |