CodeForce-812C Sagheer and Nubian Market(二分)
Sagheer and Nubian Market
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
// #define _ ios::sync_with_stdio(false)
// #define cin.tie(0)
#define PI 3.141592653
using namespace std;
// #define rep(i,x,y) for(int i=x;i<y;i++)
const int INF = 10000000;
const int MAXN = 200050;
typedef long long ll; struct st
{
ll id;
ll val;
ll sum;
}a[100050];
bool cmp(st a,st b)
{
return a.sum<b.sum;
}
int main()
{
int n;
ll s;
cin>>n>>s;
for(int i=1;i<=n;i++)
{
cin>>a[i].val;
a[i].id=i;
}
int result=0;
ll t=0;
int low=0,high=n;
while(low<=high)
{
int mid=(low+high)/2;
for(int i=1;i<=n;i++)
{
a[i].sum=a[i].val+a[i].id*mid;
}
ll sm=0;
sort(a+1,a+1+n,cmp);
for(int i=1;i<=mid;i++)
{
sm+=a[i].sum;
if(sm>s)
{break;}
}
if(sm<=s)
{
result=mid;
t=sm;
low=mid+1;
}
else
high=mid-1;
}
cout<<result<<" "<<t<<endl;
return 0;
}
CodeForce-812C Sagheer and Nubian Market(二分)的更多相关文章
- 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 件物品的价格, 这些物品的价 ...
- CF812C Sagheer and Nubian Market 二分+贪心
模拟赛给他们出T1好了~ code: #include <bits/stdc++.h> #define ll long long #define N 100006 #define setI ...
- AC日记——Sagheer and Nubian Market codeforces 812c
C - Sagheer and Nubian Market 思路: 二分: 代码: #include <bits/stdc++.h> using namespace std; #defin ...
- 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 ...
- CF812C Sagheer and Nubian Market
CF812C Sagheer and Nubian Market 洛谷评测传送门 题目描述 On his trip to Luxor and Aswan, Sagheer went to a Nubi ...
- 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 ...
随机推荐
- openstack June all-in-one 安装手册
by lt,hyc 1.安全规范 表1:openstack用户和密码值设置 用户名 含义 本文的设置值 Admin openstack管理员用户 ADMIN_PASS Keystone openst ...
- Vue系列-03-vue-cli自动化工具
使用Vue-CLI创建项目 安装vue-cli脚手架 Mac安装vue-cli脚手架 lichengguo@lichengguodeMacBook-Pro ~ % sudo npm install - ...
- 活久见!TCP两次挥手,你见过吗?那四次握手呢?
活久见!TCP两次挥手,你见过吗?那四次握手呢? 文章持续更新,可以微信搜一搜「小白debug」第一时间阅读,回复[教程]获golang免费视频教程.本文已经收录在GitHub https://git ...
- 关于 phpstudy环境下在MySQL中执行into outfile无法导入导出文件解决方法
之前在做sqli-labs练习,需要用到into outfile 出现以下问题: 执行SQL语句后在指定的路径下无文件生成. 例如: 执行 select into outfile "C:\\ ...
- css - rem和vw
css - rem和vw 物理像素 物理像素在不同的设备中1px里可以容纳的像素颗粒是不相同的,所以1px这个单位其实也是有N个像素颗粒填充的.同一尺寸屏幕的每个像素点所能容纳的像素颗粒越多显示效果越 ...
- SpringCloud商品服务调用方式之feign
简介:改造电商项目 order-service服务 调用商品服务获取商品信息 Feign: 伪RPC客户端(本质还是用http) 官方文档: https://cloud.spring.io/sprin ...
- ES6扩展——字符串部分新的方法
1.padStart padEnd(count, 字符串) 补全字符串 //padStart(num,str) padEnd补全一个字符串的长度 //num表示补全到几位,str是用来填充的字符串 { ...
- ES6扩展——模板字符串
${ } 模板字符串占位符 需要用反引号` ` 1.模板字符串 `${变量}` const xiaoming = { name:'xiaoming', age:14, say1:function(){ ...
- Ubuntu下安装Python3(与旧Python2版本共存)
官网下载Python3的源码 进行配置,在源码目录运行如下命令. ./configure --prefix=/usr/local/python3 --enable-shared 进行编译,在源码目录运 ...
- 并发编程之:Lock
大家好,我是小黑,一个在互联网苟且偷生的农民工. 在之前的文章中,为了保证在并发情况下多线程共享数据的线程安全,我们会使用synchronized关键字来修饰方法或者代码块,以及在生产者消费者模式中同 ...