#include #include #include #include #define pb push_back #define ll long long #define pii pair #define debug using namespace std; #define maxn 505 int freq[maxn]; int dp[maxn][maxn]; int get(int pos,int k){ if(pos <= 1) return 0; int & ret = dp[pos][k]; if(ret+1) return ret; ret = 999999999; int tot = 0; for(int i=pos;i>=1;i--){ tot += (pos-i) * freq[i]; if(k > 1 || i == 1) ret = min(ret, get(i-1,k-1) + tot); } return ret; } int main(){ int n,k; scanf("%d%d",&n,&k); int mx = 0; for(int i=0;i