模拟赛给他们出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. asp.net core-7.在Core Mvc中使用Options

    1,添加asp.net core mvc应用程序 2,添加Controllers控制器文件夹,Views视图文件夹 然后在Startup类中ConfigureServices方法中注册一下servic ...

  2. hdu 6377 度度熊看球赛 (dp)

    大意: $n$对情侣, $2n$个座位, 对于一个方案, 若$k$对情侣相邻, 则喧闹值增加$D^k$, 求喧闹值期望. 跟CF 840C一样, 设$dp[i][j]$为$i$个人, 有$j$对情侣相 ...

  3. 关于财务YT知识点

    1 YT 将今年剩余的未花完的money做YT,生成一个YT号,用在下一年使用的机制. 2 生成YT的方式 2.1 PR生成YT 2.2 PO生成YT 2.3 TR生成YT 2.4 预算直接生成YT ...

  4. 怎样手写实现 new 命令的功能

    实现new命令的功能, 首先需要知道new命令都做了些什么: 第一步: 创建一个空对象, 作为实例对象的容器; 第二步: 将空对象的prototype指向构造函数的prototype; 第三步: 将空 ...

  5. java 框架-缓冲-Redis 2Jedis操作

    https://www.cnblogs.com/wlandwl/p/redis.html Redis介绍及Jedis基础操作   1.Redis简介 Redis 是一个开源(BSD许可)的,内存中的数 ...

  6. buffer 与 cache 的区别

    Buffer 和 Cache buffer 和 cache 同样作为缓存,他们之间有什么区别呢? 简单来说,buffer 是即将要写入磁盘的缓存,而 cache 是从磁盘中读出来放到缓存的 参考来自: ...

  7. Opencl 学习笔记

    1. HelloWorld

  8. GraphQL实战篇(一)

    看过基础篇的都知道,GraphQL创建Schema有两种方式,Schema First和Graph Type,前者使用GraphQL Schema Language类似于EF的DB First:后者和 ...

  9. VBA消息框(MsgBox)(五)

    MsgBox函数显示一个消息框,并等待用户点击一个按钮,然后根据用户点击的按钮执行相关的操作. 语法 MsgBox(prompt[,buttons][,title][,helpfile,context ...

  10. dubbo常见异常及解决方式

    1.出现RpcException: Failed to invoke the method post in the service com.xxx.xxx.xxx异常怎么办?表示调用失败1.检查网络是 ...