Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int a[101];
  6.  
  7. int main(){
  8. int t, b, p, f, h, c,summ;
  9.  
  10. cin >> t;
  11. for (int i = 0;i < t; ++i){
  12. summ = 0;
  13. cin >> b >> p >> f;
  14. cin >> h >> c;
  15. if (b < 2){
  16. continue;
  17. }
  18. if (h > c){
  19. while (b > 1 && p >= 1){
  20. b-=2;
  21. p-=1;
  22. summ+=h;
  23. }
  24. if (b > 1 && f >= 1){
  25. while ( b > 1 && f >= 1 ) {
  26. b-=2;
  27. f-=1;
  28. summ+=c;
  29. }
  30. }
  31. } else {
  32. while (b > 1 && f >= 1){
  33. b-=2;
  34. f-=1;
  35. summ+=c;
  36. }
  37. if (b > 1 && p >= 1){
  38. while ( b > 1 && p >= 1 ) {
  39. b-=2;
  40. p-=1;
  41. summ+=h;
  42. }
  43.  
  44. }
  45. }
  46. b = 0;
  47. p = 0;
  48. f = 0;
  49. h = 0;
  50. c = 0;
  51.  
  52. a[i] = summ;
  53. }
  54. for (int i = 0; i < t ;++i){
  55. cout << a[i] << endl;
  56. }
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement