The Fair Nut likes kvass very much. On his birthday parents presented him nn kegs of kvass. There are vivi liters of kvass in the ii-th keg. Each keg has a lever. You can pour your glass by exactly 11 liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his glass by ss liters of kvass. But he wants to do it, so kvass level in the least keg is as much as possible.

Help him find out how much kvass can be in the least keg or define it's not possible to pour his glass by ss liters of kvass.

Input

The first line contains two integers nn and ss (1≤n≤1031≤n≤103, 1≤s≤10121≤s≤1012) — the number of kegs and glass volume.

The second line contains nn integers v1,v2,…,vnv1,v2,…,vn (1≤vi≤1091≤vi≤109) — the volume of ii-th keg.

Output

If the Fair Nut cannot pour his glass by ss liters of kvass, print −1−1. Otherwise, print a single integer — how much kvass in the least keg can be.

Examples

Input
3 3
4 3 5
Output
3
Input
3 4
5 3 4
Output
2
Input
3 7
1 2 3
Output
-1

Note

In the first example, the answer is 33, the Fair Nut can take 11 liter from the first keg and 22 liters from the third keg. There are 33 liters of kvass in each keg.

In the second example, the answer is 22, the Fair Nut can take 33 liters from the first keg and 11 liter from the second keg.

In the third example, the Fair Nut can't pour his cup by 77 liters, so the answer is −1−1.

 #include <cstdio>
#include <iostream> using namespace std; long long v[]; int main()
{
long long n;
long long s;
scanf("%lld %lld",&n,&s);
for(int i=;i<n;++i)
{
scanf("%lld",&v[i]);
} long long min_v=v[];
for(int i=;i<n;++i)
{
if(min_v>v[i])
{
min_v=v[i];
}
} long long sum=;
for(int i=;i<n;++i)
{
sum+=v[i]-min_v;
} long long left=,right=min_v,k=-; while(left<=right)
{
long long mid=(left+right)>>;
if(sum+(min_v-mid)*n >= s)
{
k=max(mid,k);
left=mid+;
}
else
{
right=mid-;
}
} printf("%d\n",k); return ;
}

A - Kvass and the Fair Nut 二分的更多相关文章

  1. B. Kvass and the Fair Nut

    B. Kvass and the Fair Nut time limit per test 1 second memory limit per test 256 megabytes input sta ...

  2. CF1083E The Fair Nut and Rectangles

    CF1083E The Fair Nut and Rectangles 给定 \(n\) 个平面直角坐标系中左下角为坐标原点,右上角为 \((x_i,\ y_i)\) 的互不包含的矩形,每一个矩形拥有 ...

  3. CF 1083 B. The Fair Nut and Strings

    B. The Fair Nut and Strings 题目链接 题意: 在给定的字符串a和字符串b中找到最多k个字符串,使得不同的前缀字符串的数量最多. 分析:  建出trie树,给定的两个字符串就 ...

  4. CF 1083 A. The Fair Nut and the Best Path

    A. The Fair Nut and the Best Path https://codeforces.com/contest/1083/problem/A 题意: 在一棵树内找一条路径,使得从起点 ...

  5. CF1083A The Fair Nut and the Best Path

    CF1083A The Fair Nut and the Best Path 先把边权搞成点权(其实也可以不用),那么就是询问树上路径的最大权值. 任意时刻权值非负的限制可以不用管,因为若走路径 \( ...

  6. Codeforces Round #526 (Div. 2) E. The Fair Nut and Strings

    E. The Fair Nut and Strings 题目链接:https://codeforces.com/contest/1084/problem/E 题意: 输入n,k,k代表一共有长度为n的 ...

  7. Codeforces Round #526 (Div. 2) D. The Fair Nut and the Best Path

    D. The Fair Nut and the Best Path 题目链接:https://codeforces.com/contest/1084/problem/D 题意: 给出一棵树,走不重复的 ...

  8. Codeforces Round #526 (Div. 2) C. The Fair Nut and String

    C. The Fair Nut and String 题目链接:https://codeforces.com/contest/1084/problem/C 题意: 给出一个字符串,找出都为a的子序列( ...

  9. C. The Fair Nut and String 递推分段形dp

    C. The Fair Nut and String 递推分段形dp 题意 给出一个字符串选择一个序列\({p_1,p_2...p_k}\)使得 对于任意一个\(p_i\) , \(s[p_i]==a ...

随机推荐

  1. Linux服务器上python2升为python3.6

    如何在在Linux服务器上吧Python2升级为Python3 最近白嫖了一年的服务器,打算在服务器上跑一个Python项目,没想到居然预装的是Python2.7.5.本来是打算把Python2.7. ...

  2. 每日一练PAT_B_PRAC_1005斐波那契凤尾

    NowCoder号称自己已经记住了1-100000之间所有的斐波那契数.为了考验他,我们随便出一个数n,让他说出第n个斐波那契数.当然,斐波那契数会很大.因此,如果第n个斐波那契数不到6位,则说出该数 ...

  3. AI产品经理工作流程——需求分析和产品设计

    1.AI产品设计常见失败原因 技术驱动产品设计,即我有什么技术就做什么产品.尽管许多公司不惜重金招聘高级AI算法工程师,确实这样也能帮助企业拿到大量的融资,但也容易给公司带来技术决定产品设计的局限.然 ...

  4. Codeforces 1248C Ivan the Fool and the Probability Theory(推公式)

    题意 一个n*m的网格图,每个格子可以染黑色.白色,问你每个格子最多有一个相邻颜色相同的方案数 n,m<=1e5 思路 我们先处理\(1 \times m\)的情况 设\(f[i][j]\)为前 ...

  5. SpingBoot错误信息处理及原理

    SpringBoot错误信息处理机制 在一个web项目中,总需要对一些错误进行界面或者json数据返回,已实现更好的用户体验,SpringBoot中提供了对于错误处理的自动配置 ErrorMvcAut ...

  6. Burpsuite--安装和环境配置

    1.引子 Burpsuite是一款安全人员常用的工具.在渗透测试中,我们使用Burp Suite将使得测试工作变得更加容易和方便,即使在不需要娴熟的技巧的情况下,只有我们熟悉Burp Suite的使用 ...

  7. finished with exit code -1073740791 (0xC0000409)解决方案

    1.在用keras框架跑NER的train时,而且只是在用了keras_contrib.layers的CRF时出现问题: 遇到无错跳出finished with exit code -10737407 ...

  8. JDK14都要问世了,你还在用JDK8吗

    Java开发工具包(JDK)14已进入发布候选阶段,总体功能基本已确定.计划中的标准Java升级将具有新功能,例如JDK Flight Recorder事件流,模式匹配和开关表达式. JDK 14计划 ...

  9. bin utilities related

    objdump -S,如果有源程序的话,将源程序与汇编代码混合在一起. 使用该选项时,输入的目标文件需要有调试信息,即用gcc -g生成的目标文件才可以,因为,调试信息中采用源程序信息. objcop ...

  10. web访问 FastDFS 方法思路

           由于余老师在 V4.05 以后的版本就把内置 HTTP服务去掉了,所以就算这篇你测试上传成功了,你也访问不了. 推荐大家结合 Nginx 使用 fastdfs-nginx-module ...