174A - Problem About Equation - CodeForces Solution


math *1100

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
#define debug_ok cout<<"debug_ok"<<endl;
#define optimize ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define vtr vector<int>
#define pb push_back
const int INF=1e9+7;
const int N=1e7+7;
const int MOD=1e9+7;
void solve()
{
	double n,b;
	cin>>n>>b;
	std::vector<int> v;
	double pre_sum = 0;
	for(int i = 0 ;i<n;i++)
	{
		int x;
		cin>>x;
		v.push_back(x);
		pre_sum+=x;
	}
	double total = pre_sum + b;
	double per_person = total/n;
	bool flag = true;
	for(int i = 0;i<n;i++)
	{
		if(v[i]>per_person)flag = false;
	}
	
		if(flag)
		{	for(int i = 0;i<n;i++){
			double k = per_person-v[i];
		    printf("%.7f\n",k);
		}
	}
	else cout<<-1<<endl;
}
signed main()
	{
		solve();
	}


Comments

Submit
0 Comments
More Questions

901A - Hashing Trees
1283A - Minutes Before the New Year
1654D - Potion Brewing Class
1107B - Digital root
25A - IQ test
785A - Anton and Polyhedrons
1542B - Plus and Multiply
306A - Candies
1651C - Fault-tolerant Network
870A - Search for Pretty Integers
1174A - Ehab Fails to Be Thanos
1169A - Circle Metro
780C - Andryusha and Colored Balloons
1153A - Serval and Bus
1487C - Minimum Ties
1136A - Nastya Is Reading a Book
1353B - Two Arrays And Swaps
1490E - Accidental Victory
1335A - Candies and Two Sisters
96B - Lucky Numbers (easy)
1151B - Dima and a Bad XOR
1435B - A New Technique
1633A - Div 7
268A - Games
1062B - Math
1294C - Product of Three Numbers
749A - Bachgold Problem
1486B - Eastern Exhibition
1363A - Odd Selection
131B - Opposites Attract