Advertisement
Saleh127

CF 1417A

Sep 27th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 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.  
  11. test
  12. {
  13. ll n,k,a[20000],c,d,e=0,f,i,j,l;
  14. cin>>n>>k;
  15. for(i=0;i<n;i++)
  16. {
  17. cin>>a[i];
  18. }
  19. sort(a,a+n);
  20. for(i=n-1;i>=0;i--)
  21. {
  22. for(j=0;j<n;j++)
  23. {
  24. if(i==j) continue;
  25. if(a[i]+a[j]<=k)
  26. {
  27. while(1)
  28. {
  29. if(a[i]+a[j]<=k)
  30. {
  31. e++;
  32. a[i]+=a[j];
  33. }
  34. else break;
  35. }
  36. }
  37. else if(a[i]+a[j]>k)
  38. {
  39. break;
  40. }
  41. }
  42. }
  43. cout<<e<<endl;
  44. }
  45.  
  46.  
  47. return 0;
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement