rengetsu

Baltic_ACM_ICPC_E

Oct 12th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. // Baltic ACM ICPC E
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6.     int t1,t2,t3,n, var, ats=0;
  7.     cin >> t1 >> t2 >> t3 >> n;
  8.     while(n>0)
  9.     {
  10.         if(n>=3)
  11.         {
  12.             n-=3;
  13.             if(t1>=t2 && t1>=t3){var=(t1+t2)+t1;}
  14.             else if(t2>=t3 && t2>=t1){var=(t1+t2)+t2;}
  15.             else if(t3>=t2 && t3>=t1){var=(t1+t2)+t3;}
  16.             ats+=var;
  17.         }
  18.         else
  19.         {
  20.             if(t1>=t2 && t1>=t3)
  21.             {
  22.                 n-=1;
  23.                 ats+=t1;
  24.             }
  25.             else if(t2>=t1 && t2>=t3)
  26.             {
  27.                 n-=1;
  28.                 ats+=t2;
  29.             }
  30.             else if(t3>=t1 && t3>=t1)
  31.             {
  32.                 n-=1;
  33.                 ats+=t3;
  34.             }
  35.         }
  36.     }
  37.     cout << ats << endl;
  38.     return 0;
  39. }
Add Comment
Please, Sign In to add comment