Advertisement
Zinak

Untitled

Aug 22nd, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int n,b,p,f,h,c,d,e,ans=0,g;
  6. cin>>n;
  7. while(n--)
  8. {
  9. cin>>b>>p>>f;
  10. cin>>h>>c;
  11. ans=0;
  12. if(h>=c)
  13. {
  14. if(b>=p*2)
  15. {
  16. g=p*2, b-=g;
  17. ans+=(p*h);
  18. if(b>1)
  19. f=min(b/2,f), ans+=(f*c);
  20. }
  21. else
  22. p=b/2, ans+=(p*h);
  23. }
  24. else
  25. {
  26. if(b>=e*2)
  27. {
  28. g=e*2, b-=g;
  29. ans+=(f*c);
  30. if(b>1)
  31. p=min(b/2,p), ans+=(p*h);
  32. }
  33. else
  34. f=b/2, ans+=(f*c);
  35. }
  36. cout<<ans<<endl;
  37. }
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement