Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1.     #include <bits/stdc++.h>
  2.     using namespace std;
  3.      
  4.     const int N = 1e5+10;
  5.      
  6.     int arr[4];
  7.     char op[3];
  8.      
  9.     bool cmp(int i,int j)
  10.     {
  11.         return i<j;
  12.     }
  13.      
  14.     int main()
  15.     {
  16.         ios::sync_with_stdio(0);
  17.         cin.tie(NULL);
  18.         cout.tie(NULL);
  19.      
  20.         #ifndef ONLINE_JUDGE
  21.             //freopen("input.txt", "r", stdin);
  22.             //freopen("out.txt", "w", stdout);
  23.         #endif // ONLINE_JUDGE
  24.      
  25.      
  26.         for(int i=0;i<4;i++)
  27.             cin>>arr[i];
  28.         for(int i=0;i<3;i++)
  29.             cin>>op[i];
  30.         sort(arr,arr+4);
  31.         sort(op,op+3,cmp);
  32.         for(int i=0;i<3;i++)
  33.         {
  34.             if(op[i]=='*')
  35.                 arr[i+1]=arr[i]*arr[i+1];
  36.             else
  37.                 arr[i+1]=arr[i]+arr[i+1];
  38.             sort(arr,arr+4);
  39.         }
  40.         cout<<arr[3];
  41.         //cout << ans;
  42.         return 0;
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement