Sreekar_0125

Untitled

Mar 3rd, 2024
840
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.90 KB | None | 0 0
  1. //Author: D. Nisritha Reddy
  2. #include<bits/stdc++.h>
  3. #define int long long
  4. #define pb push_back
  5. #define ndl "\n"
  6. #define yes cout<<"YES\n"
  7. #define no cout<<"NO\n"
  8. #define mod (int)(1e9 + 7)
  9. #define F first
  10. #define S second
  11. #define vi vector<int>
  12. #define vc vector<char>
  13. #define vpi vector<pair<int,int>>
  14. #define pi pair<int,int>
  15. #define mi map<int, int>
  16. #define miv map<int,vector<int>>
  17. using namespace std;
  18.  
  19. template<class T>
  20. void inp(vector<T>&a){ for(auto &x : a)cin>>x; }
  21.  
  22. template<class T>
  23. void print(vector<T>&a){
  24.     for(auto &x: a)cout<<x<<" ";
  25.     cout<<ndl;
  26. }
  27.  
  28. template<class T>
  29. void print(T x){cout<<x<<" ";}
  30.  
  31. template<class T>
  32. void println(T x){ cout<<x<<"\n";}
  33.  
  34. template<class T>
  35. T maxEle(vector<T>&a){
  36.     T maxi = LLONG_MIN;
  37.     for(auto x : a)
  38.         if(x>maxi)maxi = x;
  39.     return maxi;
  40. }
  41.  
  42. template<class T>
  43. T minEle(vector<T>&a){
  44.     T mini = LLONG_MAX;
  45.     for(auto x: a)
  46.         if(x<mini) mini = x;
  47.     return mini;
  48. }
  49.  
  50. template<class T>
  51. void sortAll(vector<T>&a){ sort(a.begin(), a.end());}
  52.  
  53. template<class T>
  54. T sumAll(vector<T>&a){
  55.     T sum = 0;
  56.     for(auto x : a) sum +=x;
  57.     return sum;
  58. }
  59.  
  60. template<class T>
  61. void revAll(vector<T>&a){reverse(a.begin(),a.end());}
  62.  
  63.  
  64.  
  65. ///////////////////////////////////////////////////////////////////////////////////////////////////
  66.  
  67.  
  68.  
  69.  
  70. void solve(){
  71.    
  72.     vi a(3); inp(a);
  73.    
  74.     sortAll(a);
  75.    
  76.     if(a[0] + a[1] < a[2]){
  77.        
  78.         a[2] = a[2] - (a[0] + a[1]);
  79.        
  80.         cout<<(a[0] + a[1]) + a[2]<<"\n";
  81.    
  82.     }
  83.    
  84.     else{
  85.        
  86.         cout<<(a[0] + a[1] + a[2] + 1)/2<<"\n";
  87.     }
  88.    
  89.    
  90. }
  91.  
  92.  
  93.  
  94. ///////////////////////////////////////////////////////////////////////////////////////////////////
  95.  
  96.  
  97.  
  98. signed main(){
  99.    
  100.     ios_base::sync_with_stdio(false);
  101.     cin.tie(NULL);
  102.  
  103.     int t = 1; //cin>>t;
  104.     while(t--){
  105.         solve();
  106.     }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment