Advertisement
Saleh127

CF 208D

Sep 29th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 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. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. ll a[1000],n,i,p[100];
  11. cin>>n;
  12. for(i=0;i<n;i++)
  13. {
  14. cin>>a[i];
  15. }
  16. for(i=0;i<5;i++)
  17. {
  18. cin>>p[i];
  19. }
  20. ll s=0,ans[5]={0};
  21. for(i=0;i<n;i++)
  22. {
  23. s+=a[i];
  24. if(s>=p[4])
  25. {
  26. ans[4]+=(s/p[4]);
  27. s%=p[4];
  28. }
  29. if(s>=p[3])
  30. {
  31. ans[3]+=(s/p[3]);
  32. s%=p[3];
  33. }
  34. if(s>=p[2])
  35. {
  36. ans[2]+=(s/p[2]);
  37. s%=p[2];
  38. }
  39. if(s>=p[1])
  40. {
  41. ans[1]+=(s/p[1]);
  42. s%=p[1];
  43. }
  44. if(s>=p[0])
  45. {
  46. ans[0]+=(s/p[0]);
  47. s%=p[0];
  48. }
  49. }
  50. for(i=0;i<5;i++)
  51. {
  52. cout<<ans[i]<<" ";
  53. }
  54. cout<<endl<<s<<endl;
  55. return 0;
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement