模拟赛给他们出T1好了~

code:

#include <bits/stdc++.h>
#define ll long long
#define N 100006
#define setIO(s) freopen(s".in","r",stdin)
using namespace std;
int n;
ll a[N],ck,A[N],S;
int check(int tmp)
{
int i,cnt=0;
for(i=1;i<=n;++i) A[i]=a[i]+1ll*tmp*i;
sort(A+1,A+1+n);
ll pp=0;
for(i=1;i<=n;++i)
{
if(pp+A[i]>S) break;
else
{
pp+=A[i];
++cnt;
if(cnt==tmp) break;
}
}
if(cnt>=tmp)
{
ck=pp;
return 1;
}
return 0;
}
int main()
{
int i,j;
// setIO("input");
scanf("%d%lld",&n,&S);
for(i=1;i<=n;++i) scanf("%lld",&a[i]);
int l=1,r=n,mid,ans=0;
for(;l<=r;)
{
mid=(l+r)>>1;
if(check(mid)) ans=mid,l=mid+1;
else r=mid-1;
}
printf("%d %lld\n",ans,ck);
return 0;
}

  

CF812C Sagheer and Nubian Market 二分+贪心的更多相关文章

  1. CF812C Sagheer and Nubian Market

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

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

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

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

  4. #417 Div2 Problem C Sagheer and Nubian Market (二分 && std::accumulate)

    题目链接 : http://codeforces.com/problemset/problem/812/C 题意 : 给你 n 件物品和你拥有的钱 S, 接下来给出这 n 件物品的价格, 这些物品的价 ...

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

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

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

  8. AC日记——Sagheer and Nubian Market codeforces 812c

    C - Sagheer and Nubian Market 思路: 二分: 代码: #include <bits/stdc++.h> using namespace std; #defin ...

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

随机推荐

  1. 2,electron 打包

    1,全局安装electron-packager npm install electron-packager -g 2,打包,进入要打包的文件夹 electron-packager . app --pl ...

  2. MySQL5.7主从从配置

    主从从,也称为级联主从,数据流向:A(主)->B(从)->C(从从),主从从级联复制. 应用场景 在主从配置的基础上,再增加一个从库,进一步提高数据安全,容灾备份. 读写分离,从库只用于查 ...

  3. (一)JMS简介

    一.简介 JMS即Java消息服务(Java Message Service)应用程序接口,是一个Java平台中关于面向消息中间件(MOM)的API,用于在两个应用程序之间,或分布式系统中发送消息,进 ...

  4. Abp 领域事件简单实践 <一>

    领域事件,是领域内发生的事件引发别的操作,其他的类可以订阅这是事件. 接着上一篇,在testOrder 上实现一个接口  IEventHandler<EntityCreatingEventDat ...

  5. CritterAI 翻译 Configuration Parameters

    翻译自: http://www.critterai.org/projects/nmgen_study/config.html 参考: http://blog.csdn.net/kun1234567/a ...

  6. nodejs入门API之path模块

    Path模块在各个系统上的差异 Path模块API解析 一.Path模块在各个系统上的差异 path模块提供用于处理文件路径和目录路径的使用工具. let path = require('path') ...

  7. vue学习(4)-组件的创建,父子组件传值,$refs

    模块化:代码逻辑 组件化:UI 组件的创建:1.

  8. Mac上搭建Web服务器--Apache

    局域网搭建 Web 服务器测试环境,因为Mac OS X 自带了 Apache 和 PHP 环境,我们只需要简单的启动它就行了. 1.命令:sudo apachectl start Apache服务器 ...

  9. xposed获取类的属性成员

    XposedBridge.log("开始获取属性:"); Field[] fields = param.thisObject.getClass().getDeclaredField ...

  10. python 链接impala执行SQL

    项目中用python来链接impala数据库最常见,一个简单的链接,获取结果. #!/usr/bin/python # -*- coding:utf-8 -*- from impala.dbapi i ...