1445B - Elimination - CodeForces Solution


greedy math *900

Please click on ads to support us..

Python Code:

for _ in [0]*int(input()):
 a,b,c,d=map(int,input().split())
 print(max(a+b,c+d))

C++ Code:

#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<iomanip>
#include<map>

/**--------------------------------**/


#define ll long long int
#define ld long double
#define ull unsigned long long int
#define pb push_back
#define pf push_front
#define en cout<<endl;
#define yes cout<<"YES"<<endl;
#define no  cout<<"NO"<<endl;
#define no1 {cout<<-1<<endl; r0}
#define no0 {cout<<0<<endl; r0}
#define yes_r { cout<<"YES"<<endl; return ; }
#define no_r { cout<<"NO"<<endl; return ; }
#define r0 return ;
#define fr first
#define sc second
#define TT ll tt;cin>>tt;while(tt--)
#define No cout << "No" << endl ;



/**-------------------------------**/

using namespace std ;

int fact(long double n )
{
    if(n == 0)
    {
        return 1;

    }
    return  n * fact(n - 1) ;
}

/**-------------------------------**/

int cnk(int n, int k)
{
    return fact(n) / (fact(k) * fact(n - k)) ;
}

/**------------------------------**/

bool even(int n)
{
    if(n%2!=0)
        return false ;

    return true ;
}

/**------------------------------**/

int fib(int n)
{
    if(n<2)
        return n ;
    else
        return (fib(n - 1) + fib(n - 2)) ;

}

/**--------------------------------**/


/**--------------------------------**/

bool all_same(string s)
{
    for(int i=0; i<s.size(); i++)
        if(s[i]!=s[0])
            return false ;

    return true ;
}

/**---------------------------------**/

bool odd(int a)
{
    if(a%2==0)
        return false ;

    return true ;
}

void softclub()
{
}


int main()
{
    ios_base::sync_with_stdio(0) ;
    cin.tie(0) ;
    cout.tie(0) ;
    TT
    {
        ll a , b , x , y ;
        cin >> a >> b >> x >> y ;
        cout << max(a + b , x + y)  << endl ;
    }









}



 	   	 		   	  			 		 	   	


Comments

Submit
0 Comments
More Questions

518. Coin Change 2
516. Longest Palindromic Subsequence
468. Validate IP Address
450. Delete Node in a BST
445. Add Two Numbers II
442. Find All Duplicates in an Array
437. Path Sum III
436. Find Right Interval
435. Non-overlapping Intervals
406. Queue Reconstruction by Height
380. Insert Delete GetRandom O(1)
332. Reconstruct Itinerary
368. Largest Divisible Subset
377. Combination Sum IV
322. Coin Change
307. Range Sum Query - Mutable
287. Find the Duplicate Number
279. Perfect Squares
275. H-Index II
274. H-Index
260. Single Number III
240. Search a 2D Matrix II
238. Product of Array Except Self
229. Majority Element II
222. Count Complete Tree Nodes
215. Kth Largest Element in an Array
198. House Robber
153. Find Minimum in Rotated Sorted Array
150. Evaluate Reverse Polish Notation
144. Binary Tree Preorder Traversal