Codeforces 1271A. Suits Solution

Solve in C++:
  1. ///**********ALLAH IS ALMIGHTY************///
  2. ///AH Tonmoy
  3. ///Department of CSE,23rd batch
  4. ///Islamic University,Bangladesh
  5. #include<iostream>
  6. #include<math.h>
  7. using namespace std;
  8. int main()
  9. {
  10. long long a,b,c,d,e,f,value=0,s1=0,s2=0,x1,x2,dd;
  11. cin>>a>>b>>c>>d>>e>>f;
  12. if(f>e)
  13. {
  14. x1=min(min(b,c),d);
  15. s1=x1*f;
  16. dd=d-x1;
  17. if(dd>0)
  18. {
  19. x2=min(a,dd);
  20. s2=x2*e;
  21. }
  22. value=s1+s2;
  23. cout<<value<<endl;
  24. }
  25. else if(e>f)
  26. {
  27. x1=min(a,d);
  28. s1=x1*e;
  29. dd=d-x1;
  30. if(dd>0)
  31. {
  32. x2=min(min(b,c),dd);
  33. s2=x2*f;
  34. }
  35. value=s1+s2;
  36. cout<<value<<endl;
  37. }
  38. else
  39. {
  40. x1=min(a,d);
  41. s1=x1*e;
  42. dd=d-x1;
  43. if(dd>0)
  44. {
  45. x2=min(min(b,c),dd);
  46. s2=x2*f;
  47. }
  48. value=s1+s2;
  49. cout<<value<<endl;
  50. }
  51. }

No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

Powered by Blogger.