CF812C Sagheer and Nubian Market 二分+贪心
模拟赛给他们出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 二分+贪心的更多相关文章
- CF812C Sagheer and Nubian Market
CF812C Sagheer and Nubian Market 洛谷评测传送门 题目描述 On his trip to Luxor and Aswan, Sagheer went to a Nubi ...
- CodeForce-812C Sagheer and Nubian Market(二分)
Sagheer and Nubian Market CodeForces - 812C 题意:n个货物,每个货物基础价格是ai. 当你一共购买k个货物时,每个货物的价格为a[i]+k*i. 每个货物只 ...
- 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 ...
- #417 Div2 Problem C Sagheer and Nubian Market (二分 && std::accumulate)
题目链接 : http://codeforces.com/problemset/problem/812/C 题意 : 给你 n 件物品和你拥有的钱 S, 接下来给出这 n 件物品的价格, 这些物品的价 ...
- Codeforces J. Sagheer and Nubian Market(二分枚举)
题目描述: Sagheer and Nubian Market time limit per test 2 seconds memory limit per test 256 megabytes in ...
- 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 ...
- 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 ...
- AC日记——Sagheer and Nubian Market codeforces 812c
C - Sagheer and Nubian Market 思路: 二分: 代码: #include <bits/stdc++.h> using namespace std; #defin ...
- 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 ...
随机推荐
- pandas中的argsort
直接通过例子看比较好理解. import pandas as pd data = [[1, 2, 3], [2, 2, 2], [7, 8, 9]] df = pd.DataFrame(data, i ...
- hdu 6375 度度熊学队列 (链表模拟)
度度熊正在学习双端队列,他对其翻转和合并产生了很大的兴趣. 初始时有 N 个空的双端队列(编号为 1 到 N ),你要支持度度熊的 Q 次操作. ①1 u w val 在编号为 u 的队列里加入一个 ...
- 音视频入门-01-认识RGB
* 音视频入门文章目录 * RGB 简介 RGB 色彩模式是工业界的一种颜色标准,是通过对红(R).绿(G).蓝(B)三个颜色通道的变化以及它们相互之间的叠加来得到各式各样的颜色的,RGB 即是代表红 ...
- a2 Bluebottle OS
a2 Bluebottle OS That is a copy of original A2 Repository Also extra ISO image A2_Rev-6498_serial-tr ...
- XCode5环境下利用crash log调试线上Crash的流程
1.前言 本文主要介绍在XCode5环境下,如何根据App自己生成的crashlog来调试真机上运行时产生的crash问题. 2. 步骤 (1)构造一段会crash的代码,并放到viewDidLoad ...
- Java面试容器,collection,list,set
1.容器指的是可以容纳其他对象的对象. 2.collection/set/list的联系和区别? (1)collection是Java集合顶级接口,存储一组不唯一,无序的对象: (2)list接口 ...
- centos搭建集群
centos 搭建集群步骤 1.使用yum安装所需要的工具 yum -y install wget vim tcl gcc make 2.下载redis并解压 cd /usr/local wget h ...
- 线段树lazy模板 luogu3372
线段树写得很少,这么基本的算法还是要会的…… #include<bits/stdc++.h> using namespace std; inline long long read() { ...
- gdb无法单步调试
使用gdb调试单步程序时如果打印提示“single stepping until exit from function xxx,which has no line number information ...
- Ubuntu系统---C++之Eclipse IDE 编译器安装
Ubuntu系统---C++之Eclipse IDE 编译器安装 Eclipse是一个基于Java的.开放源码的.可扩展的应用开发平台,它为编程人员提供了一流的Java集成开发环境(Integrate ...