- C20250070's blog
cpp
- 2022-12-12 22:48:35 @
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[101][101];
int main(){
ll n,k;
scanf("%lld %lld",&n,&k);
for(ll i=1;i<=n;i++) for(ll j=1;j<=k;j++) dp[i][j]=-0x3f3f3f3f3f3f3f;
for(ll i=1;i<=n;i++) dp[i][0]=1;
for(ll i=1;i<=n;i++){
ll x;
scanf("%lld",&x);
for(ll j=1;j<=n;j++){
if(j==i) continue;
ll kk=x%k;
kk=(k+k-j)%k;
dp[i][j]=max(dp[i][j],dp[i][kk]+x/k);
}
}
}