C - Sagheer and Nubian Market

思路:

  二分;

代码:

#include <bits/stdc++.h>

using namespace std;

#define maxn 1000005
#define ll long long ll n,s,ai[maxn],ci[maxn]; inline void in(ll &now)
{
char Cget=getchar();now=;
while(Cget>''||Cget<'') Cget=getchar();
while(Cget>=''&&Cget<='') now=now*+Cget-'',Cget=getchar();
} int main()
{
in(n),in(s);for(ll i=;i<=n;i++) in(ai[i]);
ll l=,r=n,ans=,ans_=,mid,pos;
for(;l<=r;)
{
mid=l+r>>;pos=;
for(ll i=;i<=n;i++) ci[i]=ai[i]+i*mid;
sort(ci+,ci+n+);for(ll i=;i<=mid;i++) pos+=ci[i];
if(pos<=s) ans=mid,ans_=pos,l=mid+;
else r=mid-;
}
printf("%lld %lld\n",ans,ans_);
return ;
}

AC日记——Sagheer and Nubian Market codeforces 812c的更多相关文章

  1. Sagheer and Nubian Market CodeForces - 812C (二分)

    On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friend ...

  2. CodeForce-812C Sagheer and Nubian Market(二分)

    Sagheer and Nubian Market CodeForces - 812C 题意:n个货物,每个货物基础价格是ai. 当你一共购买k个货物时,每个货物的价格为a[i]+k*i. 每个货物只 ...

  3. 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 ...

  4. Codeforces J. Sagheer and Nubian Market(二分枚举)

    题目描述: Sagheer and Nubian Market time limit per test 2 seconds memory limit per test 256 megabytes in ...

  5. CF812C Sagheer and Nubian Market

    CF812C Sagheer and Nubian Market 洛谷评测传送门 题目描述 On his trip to Luxor and Aswan, Sagheer went to a Nubi ...

  6. 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 ...

  7. 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 friend ...

  8. Codeforces Round #417 (Div. 2) C. Sagheer and Nubian Market

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  9. 【codeforces 812C】Sagheer and Nubian Market

    [题目链接]:http://codeforces.com/contest/812/problem/C [题意] 给你n个物品; 你可以选购k个物品;则 每个物品有一个基础价值; 然后还有一个附加价值; ...

随机推荐

  1. Coconuts HDU - 5925 二维离散化 自闭了

    TanBig, a friend of Mr. Frog, likes eating very much, so he always has dreams about eating. One day, ...

  2. java中new一个对象放在循环体里面与外面的区别

    首先说下问题: 这次在做项目的是出现了一个new对象在循环里面与外面造成的不同影响. 大家可以看到这个new的对象放在不同的位置产生的效果是不一样的. 经过多方查询与验证可以得出结论: * EasyU ...

  3. bzoj 5216 [Lydsy2017省队十连测]公路建设 线段树维护 最小生成树

    [Lydsy2017省队十连测]公路建设 Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 93  Solved: 53[Submit][Status][ ...

  4. [LeetCode] 1. Two Sum ☆

    Given an array of integers, return indices of the two numbers such that they add up to a specific ta ...

  5. 2015/8/9 到家了,学完了CodeCademy的Python

    昨天坐了20多个小时的硬座回家.发现在网络信号差的火车上也是学习的好地方.如果你的手机电量不足的话,带上两本书简直是绝配.我在火车上阅读了两百多页的内容,并没有多大的疲累,那样无聊的环境里面能看书学习 ...

  6. windows修改文件的修改或者创建时间

    https://www.online-tech-tips.com/computer-tips/how-to-change-the-last-modified-date-creation-date-an ...

  7. Long Parameter List(过长参数列)---要重构的味道

      一个函数,它的参数过多是不好的,不好维护和修改,易读性也差,容易出错.       消除过长参数的方法,有如下:        1.在面向对象中,你可以传递一个对象给函数,函数通过访问对象来获得参 ...

  8. 【BZOJ4884】太空猫 [DP]

    太空猫 Time Limit: 1 Sec  Memory Limit: 256 MB[Submit][Status][Discuss] Description 太空猫(SpaceCat)是一款画面精 ...

  9. RabbitMq related

    # RabbitMq related Integration of message queuing tools with systems is the usual solution to handle ...

  10. Piggy-Bank(多重背包+一维和二维通过方式)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1114 题面: Problem Description Before ACM can do anythi ...