2019山东ACM省赛F题

原题地址
这道题很简单 , 题意就是说有n个筐子 , 里面有不定量的石头。然后作者想让你把所有筐子的石头给平均一下。
然后条件是:
1.Remove a stone from one of the non-empty buckets.
2.Move a stone from one of the buckets (must be non-empty) to any other bucket (can be empty).
自己在这里犯傻了, 把2里面的can be empty 理解成了只能往空的筐子里放石头。。。
然后就是自己数组开得太大了, 来了几次SF。。。
附上代码:

#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<cstring>
using namespace std;

int main()
{
	int t;
	cin >>t;
	while(t--){
        long long  a ;
        cin >>a;
        long long  b[a+1];
        memset(b,0,sizeof(b));
        long long sum=0;
        for(long long i=0;i<a;i++){
            cin >>b[i];
            sum +=b[i];
        }
        long long  Count=0;
        sum /=a;
        for(long long  i=0;i<a;i++){
            if(b[i]>sum){
                Count +=b[i] - sum;
            }
            /*else{
                Count +=sum - b[i];
            }*/

        }
        cout<<Count <<endl;
	}
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值