CF812C.Sagheer and Nubian Market

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 a__i Egyptian pounds. If Sagheer buys k items with indices _x_1, _x_2, ..., x__k, then the cost of item x__j is a__x__j + x__j·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 S Egyptian 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?

在前往卢克索和阿斯旺的旅途中,萨格尔来到努比亚市场为朋友和亲戚购买一些纪念品。该市场有一些奇特的规则:市场中共有 nn 种不同的商品,编号从 11 到 nn。第 ii 种商品的基础价格为 aia_i 埃及镑。若萨格尔购买了 kk 件商品,其编号依次为 x1, x2, …, xkx_1,\,x_2,\,\dots,\,x_k,则第 xjx_j 件商品的价格为 axj+xj⋅ka_{x_j} + x_j \cdot k(其中 1≤j≤k1 \le j \le k)。换言之,一件商品的最终价格等于其基础价格加上其编号乘以因子 kk。

萨格尔希望在总花费不超过 SS 埃及镑的前提下,尽可能多地购买纪念品(每种商品最多购买一次)。若存在多种方案可实现最大购买数量,则他将选择其中总花费最小的方案。你能帮他完成这项任务吗?

输入格式

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 _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 105) — the base costs of the souvenirs.

第一行包含两个整数 nn 和 SS(1≤n≤1051 \leq n \leq 10^5,1≤S≤1091 \leq S \leq 10^9)—— 分别表示市场上纪念品的数量以及 Sagheer 的预算。

第二行包含 nn 个用空格分隔的整数 a1, a2, …, ana_1,\,a_2,\,\dots,\,a_n(1≤ai≤1051 \leq a_i \leq 10^5)—— 表示各纪念品的基础价格。

输出格式

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.

在一行中输出两个整数 kk 和 TT —— Sagheer 最多能购买的纪念品数量,以及购买这 kk 件纪念品所需的最小总费用。

输入输出样例

  • 输入#1

    3 11
    2 3 5

    输出#1

    2 11
  • 输入#2

    4 100
    1 2 5 6

    输出#2

    4 54
  • 输入#3

    1 7
    7

    输出#3

    0 0

说明/提示

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 8 pounds, so he cannot buy it.

在第一个例子中,他无法购买这三件商品,因为它们的价格分别为 [5, 9, 14],总价格为 28。如果他决定只购买其中两件,则对应的价格为 [4, 7, 11]。因此,他能够负担得起第一件和第二件商品。

在第二个例子中,他可以购买所有商品,因为它们的价格分别为 [5, 10, 17, 22]。

在第三个例子中,市场上只有一件纪念品,价格为 8 英镑,因此他无法购买。

输入解题思路,AI测评打分。不知道怎么写?

首页