PUBG Tournament- Editorial || PUBG01

PROBLEM LINK: PUBG Tournament | CodeChef

Problem Code: PUBG Tournament | CodeChef

Contest : Campus Code August Edition Coding Competition | CodeChef

Author: Codechef Adgitm Chapter : https://www.codechef.com/users/test_account_9
Tester: Codechef Adgitm Chapter : https://www.codechef.com/users/test_account_9
Editorialist: Codechef Adgitm Chapter : https://www.codechef.com/users/test_account_9

DIFFICULTY:

Cake Walk

PREREQUISITES:

Mathematics

PROBLEM:

You just won a PUBG tournament with a prize money XX, the bonus is to be distributed to all the players from the prize money you got. given the total travel expense and accommodation charges for each player find out how much bonus will everyone get.

Note: In case travel and accommodation charges are more than prize money distributed bonus is 0. distributed money is to be rounded off to the floor of the decimal value.

EXPLANATION:
Calculate prize money for each player by subtraction and division.

SOLUTION:
C++:

#include<bits/stdc++.h>

define ll long long

using namespace std;
int main(){
ll n;
cin>>n;
ll x;
cin>>x;
ll acc[n],travel[n];
for(ll i=0;i<n;i++){
cin>>travel[i];
cin>>acc[i];
}
ll total=0;
for(ll i=0;i<n;i++)
total+=acc[i]+travel[i];
if(total>=x)
cout<<“0”<<endl;
else
cout<<floor((x-total)/n)<<endl;
return 0;
}