B. Kvass and the Fair Nut
B. Kvass and the Fair Nut
time limit per test: 1 second
每次测试的时间限制:1秒
memory limit per test: 256 megabytes
每次测试的内存限制:256兆字节
input. standard input
投入。标准输入
output: standard output
产出:标准产出
The Fair Nut likes kvass very much. On his birthday parents presented him n kegs of kvass. There are Ui; liters of kvass in the i-th keg.
集市螺母非常喜欢kvass。在他生日那天,父母送给他一桶克瓦斯。在第一桶里有一升的克瓦斯。
Each keg has a lever. You can pour your glass by exactly 1 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to
每个桶都有一个杠杆。你可以用1升的拉力把你的杯子倒出来。集市螺母非常喜欢这种饮料,所以他想
pour his glass by 8 liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.
把他的杯子倒8升。但是他想这么做,所以在最小的桶里的kvass水平是尽可能多的。
Help him find out how much kvass can be in the least keg or define it’s not possible to pour his glass by 8 liters of kvass.
帮助他找出有多少千瓦塞可以在最小的桶或定义这是不可能倒他的杯子8升千瓦塞。
Input
输入
The first line contains two integers nand 8(1 < n< 10*,1< s
第一行包含两个整数NAND 8(1<n<10*,1<s)
< 1012)- the number of kegs and glass volume.
<1012)-桶数和玻璃体积。
The second line contains n integers V1, De…vn(1≤Vq < 10%)- the volume of ith keg.
第二行包含n个整数V1,de.vn(1≤vq<10%)–ith keg的体积。
Output
输出量
If the Fair Nut cannot pour his glass by 8 liters of kvass, print - 1. Otherwise, print a single integer一how much kvass in the least keg can
如果公平螺母不能倒入他的杯子8升kvass,打印-1。否则,打印一个整数一多少kvass在最小的桶可以。
be.
是的。
模拟
long long a[1005];
long long sum=0;
long long MIN=1e16;
int main(){
long long n,l;
cin>>n>>l;
for(int i=0;i<n;++i){
cin>>a[i];
sum+=a[i];
MIN=min(a[i],MIN);
}
if(sum<l){
cout<<-1<<endl;
return 0;
}
else if(sum==l){
cout<<0<<endl;
return 0;
}
else{
long long q=0;
for(int i=0;i<n;++i){
q+=abs(a[i]-MIN);
}
if(q>=l){
cout<<MIN<<endl;
return 0;
}else{
long long xx=l-q;
long long lev=ceil(1.0*xx/n);
cout<<MIN-lev<<endl;
}
}
return 0;
}