fork download
  1. #include<bits/stdc++.h>
  2. #define file "dprcdiv"
  3.  
  4. using namespace std;
  5.  
  6. #define int long long
  7. #define ld long double
  8. #define pii pair<int,int>
  9. #define pb push_back
  10. #define mp make_pair
  11. #define X first
  12. #define Y second
  13. #define lb lower_bound
  14. #define ub upper_bound
  15. #define all(x) x.begin(), x.end()
  16. #define sz(x) x.size()
  17.  
  18. const int N=1e6+5;
  19. const int NN=1e3+9;
  20. const int MOD=1e9+7;
  21. const int dx[4]={0, -1, 0, 1};
  22. const int dy[4]={-1, 0, 1, 0};
  23. const int INF=1e18;
  24. const ld eps=1e-6;
  25. const ld pi=acos(-1.0); // 48 digits
  26.  
  27. int n, m;
  28. int a[N];
  29. bool dp[NN], f[NN];
  30.  
  31. void process() {
  32. // Code here :V
  33. cin>>n>>m;
  34. for (int i=1;i<=n;i++) {
  35. cin>>a[i];
  36. a[i]%=m;
  37. }
  38. f[0]=1;
  39. for (int i=1;i<=n;i++) {
  40. for (int j=0;j<m;j++)
  41. dp[j]=f[((j-a[i])%m+m)%m];
  42. // cout<<a[i]<<endl;
  43. // for (int j=0;j<m;j++)
  44. // cout<<"mod "<<j<<" "<<dp[j]<<endl
  45. if (dp[0]) {
  46. cout<<"YES";
  47. return;
  48. }
  49. for (int j=0;j<m;j++)
  50. f[j]=(dp[j] || f[j]);
  51. }
  52. cout<<"NO";
  53. }
  54.  
  55. signed main() {
  56. cin.tie(0)->sync_with_stdio(0);
  57. // freopen(file".inp","r",stdin);
  58. // freopen(file".out","w",stdout);
  59. int t=1;
  60. // cin>>t;
  61. while (t--) process();
  62. return 0;
  63. }
  64.  
Success #stdin #stdout 0.01s 5288KB
stdin
6 6
5 5 5 5 5 5
stdout
YES