Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
The mayor of your city has decided to throw a party to gather the favour of his people in different regions of the city.
There are 3 distinct regions in the city namely A, B, C comprising of PA, PB and PC number of people respectively.
However, the mayor knows that people of the region B are in conflict with people of regions A and C. So, there will be a conflict if people from region BB are present at the party along with people from region A or C.
The mayor wants to invite as many people as possible and also avoid any conflicts. Help him invite maximum number of people to the party.
For each test case, output the maximum number of people that can be invited to the party.
Input:
3
2 3 4
1 5 2
8 8 8
Output:
6
5
16
Test case-1: Mayor can invite all the people from region A and C. So the maximum number of people invited is 6.
Test case-2: Mayor can invite all the people from region B. So the maximum number of people invited is 5.
#include <bits/stdc++.h>
using namespace std;
int main(){
int t,Pa,Pb,Pc;
cin>>t;
while(t--){
cin>>Pa>>Pb>>Pc;
if(Pa+Pc>Pb){
cout<<Pa+Pc<<endl;
}
else
cout<<Pb<<endl;
}
}
# cook your dish here
t=int(input())
for i in range(t):
a,b,c=map(int,input().split())
print(max((a+c),b))
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0){
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if((a+c)>b)
System.out.println(a+c);
else if((a+c)<b)
System.out.println(b);
else if((a+c)==b)
System.out.println(b);
}
}
}
In our experience, we suggest you solve this Peaceful Party CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
If you are stuck anywhere between any coding problem, just visit Queslers to get the Peaceful Party CodeChef Solution
I hope this Peaceful Party CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Coding Solutions >>