A. Equalize Prices Again

滴答滴答---题目链接 

A. Equalize Prices Again

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

You are both a shop keeper and a shop assistant at a small nearby shop. You have nn goods, the ii-th good costs aiai coins.

You got tired of remembering the price of each product when customers ask for it, thus you decided to simplify your life. More precisely you decided to set the same price for all nn goods you have.

However, you don't want to lose any money so you want to choose the price in such a way that the sum of new prices is not less than the sum of the initial prices. It means that if you sell all nn goods for the new price, you will receive at least the same (or greater) amount of money as if you sell them for their initial prices.

On the other hand, you don't want to lose customers because of big prices so among all prices you can choose you need to choose the minimum one.

So you need to find the minimum possible equal price of all nn goods so if you sell them for this price, you will receive at least the same (or greater) amount of money as if you sell them for their initial prices.

You have to answer qq independent queries.

Input

The first line of the input contains one integer qq (1≤q≤1001≤q≤100) — the number of queries. Then qq queries follow.

The first line of the query contains one integer nn (1≤n≤100)1≤n≤100) — the number of goods. The second line of the query contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤1071≤ai≤107), where aiai is the price of the ii-th good.

Output

For each query, print the answer for it — the minimum possible equal price of all nn goods so if you sell them for this price, you will receive at least the same (or greater) amount of money as if you sell them for their initial prices.

Example

input

Copy

3
5
1 2 3 4 5
3
1 2 2
4
1 1 1 1

output

Copy

3
2
1
#include <iostream>
#include<stdio.h>
using namespace std;

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        int ans=0;
        for(int i=0; i<n; i++)
        {
            int x;
            scanf("%d",&x);
            ans+=x;
        }
        if(ans%n==0)
            printf("%d\n",ans/n);
        else printf("%d\n",ans/n+1);
    }
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值