原题链接:http://codeforces.com/contest/1042/problem/A

Benches

There are nnn benches in the Berland Central park. It is known that aia_iai​ people are currently sitting on the iii-th bench. Another mmm people are coming to the park and each of them is going to have a seat on some bench out of nnn available.

Let kkk be the maximum number of people sitting on one bench after additional mmm people came to the park. Calculate the minimum possible kkk and the maximum possible kkk.

Nobody leaves the taken seat during the whole process.

Input

The first line contains a single integer n(1≤n≤100)n(1≤n≤100)n(1≤n≤100) — the number of benches in the park.

The second line contains a single integer m(1≤m≤10000)m(1≤m≤10000)m(1≤m≤10000) — the number of people additionally coming to the park.

Each of the next nnn lines contains a single integer ai(1≤ai≤100)a_i(1≤a_i≤100)ai​(1≤ai​≤100) — the initial number of people on the iii-th bench.

Output

Print the minimum possible kkk and the maximum possible kkk, where kkk is the maximum number of people sitting on one bench after additional mmm people came to the park.

Examples
input

4
6
1
1
1
1

output

3 7

input

1
10
5

output

15 15

input

3
6
1
6
5

output

6 12

input

3
7
1
6
5

output

7 13

Note

In the first example, each of four benches is occupied by a single person. The minimum kkk is 333. For example, it is possible to achieve if two newcomers occupy the first bench, one occupies the second bench, one occupies the third bench, and two remaining — the fourth bench. The maximum kkk is 777. That requires all six new people to occupy the same bench.

The second example has its minimum kkk equal to 151515 and maximum kkk equal to 151515, as there is just a single bench in the park and all 101010people will occupy it.

题解

我都不知道我为什么要排序 (可能是身处排序强校的缘故吧)。

代码
#include<bits/stdc++.h>
using namespace std;
int a[105],maxn,n,m;
void in(){scanf("%d%d",&n,&m);for(int i=1;i<=n;++i)scanf("%d",&a[i]);}
void ac()
{sort(a+1,a+1+n);maxn=a[n]+m;for(int i=1;i<=n;++i)m-=a[n]-a[i];if(m<0)printf("%d",a[n]);else printf("%d",a[n]+m/n+(bool)(m%n));printf(" %d",maxn);
}
int main(){in();ac();}

CF1042A Benches相关推荐

  1. UVA 11578 - Situp Benches(dp)

    题目链接:11578 - Situp Benches 题意:健♂身♂房有两个仰卧起坐坐垫,每次调整角度要花费10元/10度,每次使用要花费15,如今给定n个人的时间顺序,和所希望的角度,求最少花费 思 ...

  2. 【CodeForces - 1042A】Benches (优先队列,思维模拟,maxmin问题)

    题干: There are nn benches in the Berland Central park. It is known that aiai people are currently sit ...

  3. 使用Quartus建立第一个FPGA工程

    到 www.altera.com.cn 免费申请到Quartus网络版并且安装,这个过程非常简单. 安装好Quartus后,我们开始建立第一个FPGA工程,我们开始建立第一个FPGA工程. 打开后界面 ...

  4. Quartus II调用modelsim无缝仿真

    本篇文章为转载,写的不错,最近在学modelsim仿真,网上的教程很乱,把自己认为不错的整理贴出来,后面有机会会写个详细点的. Quartus 中调用modelsim的流程 1. 设定仿真工具  as ...

  5. [转帖]如何在quartusII中调用modelsim-altera_百度文库

    2013-04-18   13:28:19 在使用quartusII直接链接到modelsim进行仿真时,出现的问题是模块与外部连接的信号找不到,原因不清楚,不过好像把这个模块的命名改成其他就可以 来 ...

  6. modelsim-altera

    一. 1.  Go to the menu Tools > Options.  2.  In the "General" category, select "EDA ...

  7. Show Attend and Tell的词表

    dataset_Flickr8k的词表 {'a': 1, 'black': 2, 'dog': 3, 'is': 4, 'running': 5, 'after': 6, 'white': 7, 'i ...

  8. Quartus ii与Modelsim-altera 6.5b联调前仿真

    本实例使用的是Quartus ii9.1版本,Modelsim-altera版本是  Quartus ii9.1版本  对应的6.5b版本. 本实例使用的是格雷码计数器(Gray) ========= ...

  9. ModelSim入门及Testbench编写——合理利用仿真才是王道

    在入职之前曾自学了一段时间的Verilog,后来因为工作的缘故鲜有接触,就搁置下来了.后来因偶然的机会需要参与一个CPLD的小项目,又开始从零学起,有些讽刺的是,不知道如何入手工具的我又回到EDN上翻 ...

  10. 荒岛余生为什么没有打开包裹_您会带到荒岛什么办公桌设置?

    荒岛余生为什么没有打开包裹 Throughout life, you experience a lot of desks and a lot of desk setups. Real or virtu ...

最新文章

  1. linux 禅道服务器,Linux下如何搭建禅道项目管理软件
  2. JavaScript的语言组成
  3. RDKit:化合物骨架分析
  4. ospf避免环路_OSPF路由协议的区域防环机制
  5. 计算机用户删除 cmd,用命令行删XP中的用户。除administrator外
  6. Python的主要8大应用领域,你还不会吗?
  7. html 手机浏览器:屏幕适配 - 代码篇
  8. node-webki NATIVE UI API概览
  9. python中文件打开的合法模式组合_以下选项中,不是Python文件打开的合法模式组合是:...
  10. linux本地时间与utc不一致_辽宁无新增 | 北京新增本地确诊病例31例,中高考时间目前不做调整...
  11. python输入一行字符串、剔除其中所有小写字母后输出_1. 输入一行字符串,将其中的非字母字符剔除,然后将字母全部转换为大写字母,并...
  12. 老王讲设计模式(三)——单例模式
  13. 【DL-CV】正则化,Dropout
  14. 全国加油站分布数据/停车场分布/公园分布/景区分布/保护区分布/2020年poi感兴趣点
  15. python的with用法
  16. 学校校园无盘教学系统
  17. NLP - snownlp
  18. 开源GIS平台实战项目的总结
  19. 7.中文句法依存分析
  20. antv g6多次渲染问题解决

热门文章

  1. 766.托普利茨矩阵(力扣leetcode) 博主可答疑该问题
  2. mysql 当前时间的一周后_mysql查询当前时间,一天内,一周,一个月内的sql语句...
  3. php pdoconnection,php使用pdo连接报错Connection failed SQLSTATE的解决方法
  4. java fri星期转_Java日期时间以及日期相互转换
  5. html文件系统错误的是,Windows10:文件系统错误2147219196
  6. [Swift]Array(数组)扩展
  7. facade层,service 层,domain层,dao 层设计
  8. Python练习-一辆购物车的寂寞都是Alex的错
  9. scrollView滚动原理
  10. 基于raphael 的图形变化