1234A - Equalize Prices Again - CodeForces Solution


math *800

Please click on ads to support us..

Python Code:

t = int(input())
for _ in range(t):
  n = int(input())
  s = sum([int(elem) for elem in input().split()])
  print((s + n - 1) // n)

C++ Code:

#include<iostream>
using namespace std;
int main()
{
    int n,i,t,ans,sum;
    cin>>t;
    while(t--)
    {
        sum=0;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum=sum+a[i];
    }
    ans=sum/n;
    if(sum%n!=0)
        ans=ans+1;
    cout<<ans<<endl;

    }
}


Comments

Submit
0 Comments
More Questions

Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup
Ali and Helping innocent people
Book of Potion making
Duration
Birthday Party