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 ...
随机推荐
- 遗传算法 TSP(Python代码)
该代码是本人根据B站up主侯昶曦的代码所修改的. 原代码github地址:https://github.com/Houchangxi/heuristic-algorithm/blob/master/T ...
- Docker小白到实战之常用命令演示,通俗易懂
前言 上一篇大概认识了Docker,主要是从概念.架构.优点及流程方面进行阐述,并进行安装和体验: 接下来就开始进行实操学习,在演示过程中会针对关键的知识点进行归纳和总结,这里先从常用命令说起,来吧, ...
- C#给线程传递数据
目录 0. 前情说明 1. ParameterizedThreadStart类型的委托 2. 使用自定义类 3. 使用Lambda表达式 4. 参考以及文中源代码下载 shanzm-2021年8月24 ...
- xml的约束
一.DTD约束xml 1.约束介绍 由于xml的标签由用户自己定义,因此在开发的时候,每个人都可以根据自己的需求来定义xml标签,这样导致项目中的xml难以维护,因此需要使用一定的规范机制来约束xml ...
- C++基于ATL工程编写ActiveX控件步骤
参考网址: https://blog.csdn.net/whui19890911/article/details/8896554 开发环境:VS2010 开发工程:C++ATL项目 开发目的:创建Ac ...
- 使用git下载码云仓库文件步骤总结
从码云下载文件的两种方式(私服时) 1.让私服管理者复制链接,然后你加入私服: 2.生成公钥,让私服管理者添加你的公钥. 在eclipse中找到git,输入自己的登录账号和密码,下载文件到本地仓库,然 ...
- log4j.properties配置文件及详解
log4j配置文件有三个主要的组件:Logger,Appender和Layout,分别为日志类型,日志输出目的地,日志输出格式. 1. 配置日志级别及appenderName log4j.rootLo ...
- Struts中整合的强大Ognl学习(一)
测试使用了一个JavaBean的User,User中的Address单独封装再形成了一个JavaBean: 为了测试静态方法和静态变量调用,写了一个Util方法: 因为测试Ognl功能过多所以直接使用 ...
- C++:继承
共有继承(public),私有继承(private),保护继承(protected): 1.public继承: 基类成员类型 作为派生类成员 在派生类中是否可见 对派生类对象的可见性 public p ...
- python进阶(20) 正则表达式的超详细使用
正则表达式 正则表达式(Regular Expression,在代码中常简写为regex. regexp.RE 或re)是预先定义好的一个"规则字符率",通过这个"规 ...