304 North Cardinal St.
Dorchester Center, MA 02124

# Peaceful Party CodeChef Solution

## Problem – Peaceful Party CodeChef Solution

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 AB, 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.

### Input Format

• The first line contains a single integer T – the number of test cases. Then the test cases follow.
• The first line of each test case contains three integers PA​, PB​ and PC​ – number of people living in regions AB and C respectively.

### Output Format

For each test case, output the maximum number of people that can be invited to the party.

### Constraints

• 1≤T≤1000
• 1≤PA​,PB​,PC​≤1000

### Sample 1:

``````Input:
3
2 3 4
1 5 2
8 8 8
Output:
6
5
16``````

### Explanation:

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.

## Peaceful Party CodeChef Solution in C++17

``````#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;
}
}``````

## Peaceful Party CodeChef Solution in Pyth 3

``````# cook your dish here
t=int(input())
for i in range(t):
a,b,c=map(int,input().split())
print(max((a+c),b))``````

## Peaceful Party CodeChef Solution in Java

``````/* 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
{
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);
}
}
}
``````
##### Peaceful Party CodeChef Solution Review:

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

Find on CodeChef

##### Conclusion:

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 >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions