【Codeforces 1073D】Berland Fair
【链接】 我是链接,点我呀:)
【题意】
题意
【题解】
我们可以从左到右枚举一轮。
定义一个cost表示这一轮花费的钱数
如果cost+a[i]beforeT
cost>beforeT/(1+x)
x*cost>x*beforeT/(1+x)
x*cost>beforeT/(1/x+1)
x>=1
显然x越大,右边越来越大
则x*cost>beforeT/2
则newT
【代码】
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5;
const long long M = 15e6;
int n;
ll T,ans = 0;
int a[N+10];
int main(){
ios::sync_with_stdio(0),cin.tie(0);
cin >> n >> T;
for (int i = 1;i <= n;i++) cin >> a[i];
while (1){
ll sum = 0;
int cnt = 0;
for (int i = 1;i <= n;i++){
if (sum+a[i]>T){
continue;
}else{
cnt++;
sum = sum + a[i];
}
}
if (cnt==0) break;
ans = ans + T/sum*cnt;
T = T%sum;
}
cout<<ans<<endl;
return 0;
}
【Codeforces 1073D】Berland Fair的更多相关文章
- 【Codeforces 1083A】The Fair Nut and the Best Path
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 我们最后要的是一条最长的路径. 这条路径的权值和是所有点的权值和-所有边的权值和且这个值最大. 显然如果我们在某一条边上的累计的权值和< ...
- Codeforces 1073D:Berland Fair(模拟)
time limit per test: 2 secondsmemory limit per test: 256 megabytesinput: standard inputoutput: stand ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【55.70%】【codeforces 557A】Ilya and Diplomas
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 758A】Holiday Of Equality
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【16.23%】【codeforces 586C】Gennady the Dentist
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 762B】USB vs. PS/2
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【30.43%】【codeforces 746C】Tram
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【58.33%】【codeforces 747B】Mammoth's Genome Decoding
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
随机推荐
- 06_锅炉压力案例_progressbar实现
相关的native方法可以用javah来生成一个头文件.拿着这个的MainActivity,用它来生成一个头文件. Signature是当前这个方法的方法签名.() V全空参数返回的是void. /* ...
- 使用Gitalk实现静态页面评论的功能
使用静态页面的理由 本人在Github上使用github.io部署了一个静态主页,地址是http://aopstudio.github.io,用于存放一些笔记文件.虽然静态页面功能少,自动化程度低,不 ...
- 测试神器Swagger的相关使用
1.Swagger简介 swagger官网地址: https://swagger.io/ swagger官网文档介绍地址: https://swagger.io/about/ swagge是一个易 ...
- Java多线程(九) synchronized 锁对象的改变
public class MyService { private String lock = "123"; public void testMethod() { synchroni ...
- ASP.NET SQL 总结
1.SQLSERVER服务器中,给定表 table1 中有两个字段 ID.LastUpdateDate,ID表示更新的事务号, LastUpdateDate表示更新时的服务器时间,请使用一句SQL语句 ...
- 转 awr自动收集脚本
1. remote get awr report #!/usr/bin/ksh ####sample: sh awr.sh 20170515 20170516 AWR ### default it w ...
- 374 Guess Number Higher or Lower 猜数字大小
我们正在玩一个猜数字游戏. 游戏规则如下:我从 1 到 n 选择一个数字. 你需要猜我选择了哪个数字.每次你猜错了,我会告诉你这个数字是大了还是小了.你调用一个预先定义好的接口 guess(int n ...
- Eclipse里的Java EE视图在哪里?MyEclipse里的Java EE视图在哪里?MyEclipse里的MyEclipse Java Enterprise视图在哪里?(图文详解)
为什么要写这篇博客呢? 是因为,最近接触一个web项目. 然后呢,Eclipse里的Java EE视图的位置与MyEclipse里不太一样.为了自己梳理日后查找,也是为了新手少走弯路. Eclipse ...
- EasyUI系列学习(十)-Tabs(选项卡)
一.创建组件 <div class="easyui-tabs" style="width:500px;height:250px"> <div ...
- centos源码编译安装nginx过程记录
前言:Centos系统编译安装LNMP环境是每来一台新服务器或换电脑都需要做的事情.这里仅做一个记录.给初学者一个参考! 一.安装前的环境 这里用的是centos 7系统. 我们默认把下载的软件放在 ...