# MAYOR_PARTY - Editorial

Setter: Jeevan Jyot Singh
Tester: Harris Leung
Editorialist: Kanhaiya Mohan

Cakewalk

None

# PROBLEM:

There are 3 distinct regions in the city namely A, B, C consisting of P_A, P_B and P_C number of people respectively.

We know 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 B are present at the party along with people from region A or C.

You want to invite as many people as possible and also avoid any conflicts. Find the maximum number of people you can invite to the party.

# EXPLANATION:

We are given that the people of region B are in conflict with people of region A and C. This means that if people of region B come to the party, no one else comes.
On the other hand, if the people of region B do not come, people from regions A and C can come together.

The maximum number of people would be the maximum out of these two cases.
Thus, the answer is max(P_B, P_A +P_C).

# TIME COMPLEXITY:

The time complexity is O(1) per test case.

# SOLUTION:

Tester's Solution
``````#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const ll mod=998244353;
int t;
int n,m;
ll a[300001];
ll s=0;
int main(){
ios::sync_with_stdio(false);cin.tie(0);
int t;cin >> t;
while(t--){
int x,y,z;
cin >> x >> y >> z;
cout << max(y,x+z) << '\n';
}
}
``````
Editorialist's Solution
``````#include <bits/stdc++.h>
using namespace std;

int main() {
int t;
cin>>t;
while(t--){
int pa, pb, pc;
cin>>pa>>pb>>pc;
cout<<max(pb, pa+pc)<<endl;
}
return 0;
}
``````

/* 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 in = new Scanner(System.in);
int T = Integer.parseInt(in.nextLine());
int A[] = new int[T];
int B[] = new int[T];
int C[] = new int[T];

``````	for (int t = 0; t < T; t++) {

String[] input = in.nextLine().split(" ");

A[t] = Integer.parseInt(input[0]);
B[t] = Integer.parseInt(input[1]);
C[t] = Integer.parseInt(input[2]);
if(A[t]+C[t] >=B[t]){
int x = A[t]+C[t];
System.out.println(x);
}
else{
System.out.println(B[t]);
}
}
``````

}
}