Saleh127

Light oj(LO) 1233

May 18th, 2021
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. ll v[200000];
  6. int main()
  7. {
  8. ios_base::sync_with_stdio(0);
  9. cin.tie(0);
  10. cout.tie(0);
  11.  
  12. test
  13. {
  14.  
  15. ll n,m,i,j,k,h,l=0;
  16.  
  17. cin>>n>>k;
  18.  
  19. ll a[n+2],c[n+2];
  20.  
  21.  
  22. ll dp[k+5];
  23.  
  24. memset(v,0,sizeof v);
  25. memset(dp,0,sizeof dp);
  26.  
  27. dp[0]=1;
  28.  
  29. for(i=0; i<n; i++)
  30. {
  31. cin>>a[i];
  32. }
  33.  
  34. for(i=0; i<n; i++)
  35. {
  36. cin>>c[i];
  37. }
  38.  
  39. for(i=0; i<n; i++)
  40. {
  41. memset(v,0,sizeof v);
  42.  
  43. for(j=1; j<=k; j++)
  44. {
  45. if(dp[j]==0 && j-a[i]>=0 && dp[j-a[i]] && v[j-a[i]]<c[i])
  46. {
  47. l++;
  48. dp[j]=1;
  49. v[j]=v[j-a[i]]+1;
  50. }
  51. }
  52.  
  53. }
  54.  
  55. cout<<"Case "<<cs<<": "<<l<<endl;
  56.  
  57. }
  58.  
  59.  
  60. return 0;
  61. }
  62.  
Advertisement
Add Comment
Please, Sign In to add comment