Advertisement
leminhkt

noname13 (QBSEQ)

Mar 2nd, 2020
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define FOR(i, a, b) for(int i=(a); i<=(b); i++)
  3. using namespace std;
  4. int n, k;
  5. int main(){
  6.     cin>>n>>k;
  7.     vector<int> a(n), m(k, INT_MIN), tam;
  8.     m[0]=0;
  9.     for(int &i:a){
  10.         cin>>i;
  11.         i%=k;
  12.     }
  13.     for(int i:a){
  14.         tam=m;
  15.         FOR(j, 0, k-1) m[(j+i)%k]=max(tam[(j+i)%k], tam[j]+1);
  16.     }
  17.     cout<<m[0];
  18.    
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement