CodeForces - 812C Sagheer and Nubian Market 二分
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost aiEgyptian pounds. If Sagheer buys k items with indices x1, x2, ..., xk, then the cost of item xj is axj + xj·k for 1 ≤ j ≤ k. In other words, the cost of an item is equal to its base cost in addition to its index multiplied by the factor k.
Sagheer wants to buy as many souvenirs as possible without paying more than SEgyptian pounds. Note that he cannot buy a souvenir more than once. If there are many ways to maximize the number of souvenirs, he will choose the way that will minimize the total cost. Can you help him with this task?
Input
The first line contains two integers n and S (1 ≤ n ≤ 105 and 1 ≤ S ≤ 109) — the number of souvenirs in the market and Sagheer's budget.
The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 105) — the base costs of the souvenirs.
Output
On a single line, print two integers k, T — the maximum number of souvenirs Sagheer can buy and the minimum total cost to buy these k souvenirs.
Example
3 11
2 3 5
2 11
4 100
1 2 5 6
4 54
1 7
7
0 0
Note
In the first example, he cannot take the three items because they will cost him [5, 9, 14] with total cost 28. If he decides to take only two items, then the costs will be [4, 7, 11]. So he can afford the first and second items.
In the second example, he can buy all items as they will cost him [5, 10, 17, 22].
In the third example, there is only one souvenir in the market which will cost him 8pounds, so he cannot buy it.
CodeForces - 812C Sagheer and Nubian Market 二分的更多相关文章
- Codeforces J. Sagheer and Nubian Market(二分枚举)
题目描述: Sagheer and Nubian Market time limit per test 2 seconds memory limit per test 256 megabytes in ...
- CodeForce-812C Sagheer and Nubian Market(二分)
Sagheer and Nubian Market CodeForces - 812C 题意:n个货物,每个货物基础价格是ai. 当你一共购买k个货物时,每个货物的价格为a[i]+k*i. 每个货物只 ...
- 【贪心+二分】codeforces C. Sagheer and Nubian Market
http://codeforces.com/contest/812/problem/C [题意] 如何花最少的钱买最多的纪念品?首要满足纪念品尽可能多,纪念品数量一样花钱要最少,输出纪念品数量以及最少 ...
- #417 Div2 Problem C Sagheer and Nubian Market (二分 && std::accumulate)
题目链接 : http://codeforces.com/problemset/problem/812/C 题意 : 给你 n 件物品和你拥有的钱 S, 接下来给出这 n 件物品的价格, 这些物品的价 ...
- CF812C Sagheer and Nubian Market 二分+贪心
模拟赛给他们出T1好了~ code: #include <bits/stdc++.h> #define ll long long #define N 100006 #define setI ...
- AC日记——Sagheer and Nubian Market codeforces 812c
C - Sagheer and Nubian Market 思路: 二分: 代码: #include <bits/stdc++.h> using namespace std; #defin ...
- Codeforces Round #417 C. Sagheer and Nubian Market
C. Sagheer and Nubian Market time limit per test 2 seconds memory limit per test 256 megabytes O ...
- Codeforces812C Sagheer and Nubian Market 2017-06-02 20:39 153人阅读 评论(0) 收藏
C. Sagheer and Nubian Market time limit per test 2 seconds memory limit per test 256 megabytes input ...
- CF812C Sagheer and Nubian Market
CF812C Sagheer and Nubian Market 洛谷评测传送门 题目描述 On his trip to Luxor and Aswan, Sagheer went to a Nubi ...
随机推荐
- 微信小程序之多行文本省略号
最近在捣鼓小程序,期间遇到的问题,踩过的坑,也是在网上各种搜.这里也说下我解决的问题,方便大家. 在小程序首页显示文本列表的时候,为了美观,不希望把所有的文本都显示出来,希望是显示前几行(比如前3行, ...
- Farseer.net轻量级开源框架 中级篇:UrlRewriter 地址重写
导航 目 录:Farseer.net轻量级开源框架 目录 上一篇:Farseer.net轻量级开源框架 中级篇: Cookies.Session.Request 下一篇:Farseer.net轻量 ...
- 经典算法mark
在平时找工作的时候,或多或少会遇到一些算法问题,很多都是比较经典或者网上已经流传很久的.只是我们没有接触过,所以不知道怎么解决. 在这儿,我自己总结一些我遇到的一些经典算法,给自己增加一点记忆,也给需 ...
- Day3 CSS 引入及基本选择器
一 .CSS 层叠样式表,为了使网页元素的样式更加丰富,内容与样式拆分开来.HTML负责结构与内容,表现形式交给CSS. CSS注释/**/ 来注释 二.CSS基本语法与引用 CSS的语法结构 选择器 ...
- date - 打印或设置系统日期和时间
总览 date [选项]... [+格式] date [选项] [MMDDhhmm[[CC]YY][.ss]] 描述 根据指定格式显示当前时间或设置系统时间. -d, --date=STRING 显示 ...
- CAD参数绘制椭圆(网页版)
在CAD设计时,需要绘制椭圆,用户可以设置椭圆的基本属性. 主要用到函数说明: _DMxDrawX::DrawEllipse 绘制椭圆.详细说明如下: 参数 说明 DOUBLE dCenterX 椭圆 ...
- anchor_target_layer中的bounding regression
在anchor_target层,这两行是计算bounding regression代码: bbox_targets = np.zeros((len(inds_inside), 4), dtype=np ...
- Spring Boot . 4 -- 定制 Spring Boot 配置
覆写 Auto-Configuration 的类 利用外部属性进行动态配置 [本文] 定制 Error 页面 [第二篇] Spring Boot的自动配置可以节省很多无趣的配置工作,但是并不是所有的自 ...
- BZOJ 2039 人员雇佣 二元关系 最小割
题面太长了,请各位自行品尝—>人员雇佣 分析: 借用题解的描述: a.选择每个人有一个代价Ai b.如果有两个人同时选择就可以获得收益Ei,j c.如果一个人选择另一个不选会产生代价Ei,j 这 ...
- IDEA使用properties配置文件进行mysql数据路连接
1. 新建一个web项目(过程不需要教了吧,所以就省略啦) 2. 右键点击新建的项目名,选择创建文件目录(Directory),一般properties文件夹命名应为resoures; 3.右键点击新 ...