Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Baltic ACM ICPC E
- #include <iostream>
- using namespace std;
- int main()
- {
- int t1,t2,t3,n, var, ats=0;
- cin >> t1 >> t2 >> t3 >> n;
- while(n>0)
- {
- if(n>=3)
- {
- n-=3;
- if(t1>=t2 && t1>=t3){var=(t1+t2)+t1;}
- else if(t2>=t3 && t2>=t1){var=(t1+t2)+t2;}
- else if(t3>=t2 && t3>=t1){var=(t1+t2)+t3;}
- ats+=var;
- }
- else
- {
- if(t1>=t2 && t1>=t3)
- {
- n-=1;
- ats+=t1;
- }
- else if(t2>=t1 && t2>=t3)
- {
- n-=1;
- ats+=t2;
- }
- else if(t3>=t1 && t3>=t1)
- {
- n-=1;
- ats+=t3;
- }
- }
- }
- cout << ats << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment