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 ...
随机推荐
- (七)Mybatis总结之注解开发
请移步到 https://www.cnblogs.com/lxnlxn/p/5996707.html
- win7打开网络看不到局域网的其他电脑
双击打开桌面上的“网络”,在打开的窗口中看不到局域网的其他电脑/计算机.以前都可以看到的.可能是没有开启网络发现的原因,可是我并没有关闭网络发现.不知,怎么回事? Windows7查看网络邻居要开启g ...
- codeforces_D. Social Circles
http://codeforces.com/contest/1060/problem/D 题意: n个客人,每个客人希望自己左边空li个座位,右边空ri个座位,可以形成任意个圆,问最少多少个座位. 思 ...
- swift try try? try!
try You have 2 options when you try calling a function that may throw. You can take responsibility o ...
- Swift Intermediate Language (SIL)
Swift Intermediate Language (SIL) https://github.com/apple/swift/blob/master/docs/SIL.rst#witness-me ...
- Swift - 值类型与引用类型的初步探究
前言 swift中的结构体和类在组成和功能上具有一定的相似性.两者都可以含有成员属性.成员方法用于数据存储和功能性模块封装.往往造成不知如何对二者进行区分和使用 值类型概念和引用类型概念 值类型的概念 ...
- Java HTTP 组件库选型看这篇就够了
最近项目需要使用 Java 重度调用 HTTP API 接口,于是想着封装一个团队公用的 HTTP client lib. 这个库需要支持以下特性: 连接池管理,包括连接创建和超时.空闲连接数控制.每 ...
- 【VBA研究】如何用Base64 编解码方法实现简单的加解密
Base64编码的思想是是采用64个基本的ASCII码字符对数据进行重新编码,将数据变成字符串实现文本传输.由于编码简单,所以很容易实现,代码也是现成的.利用这个编码规则可以实现简单的加解密.编解码方 ...
- css 样式通用样式
属性: vertical-align (这个属性主要作用是用于将相邻的文本与元素对齐,用于对齐行内元素,也就是说,display 的属性为 inline. inline-block 行内块,顾名 ...
- 微信小程序中使用echarts
一.效果图 二.代码 import * as echarts from '../../component/ec-canvas/echarts'; const app = getApp(); var x ...