#includeusing namespace std;#define N 3005long long a[N],f[N][N];//dp数组,dp[i][j]表示前i个数中除以k的余数为j的当前最大和int n,k;int main(){ cin >> n >> k; for(int i = 1; i > a[i];} memset(f,-0x3f,sizeof f); long long maxv = -0x3f3f3f3f; f[0][0] = 0; for(int i = 1; i for(int j = 0; j f[i][j] = max(f[i - 1][(j - a[i] + k) % k] + a[i],f[i - 1][j]); //能ac的状态方程: f[i][(j + a[i]) % k] = max(f[i - 1][j] + a[i],f[i - 1][(j + a[i]) % k]); } } for(int i = 1; i if(maxv > 0)cout else cout return 0;}