【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 ...
随机推荐
- JS浮点数精度运算
一般来讲,我们在项目中必不可少的需要进行各种数值的计算,但是这种计算全部放在服务端会给服务器带来很大的压力,所以势必要客户端来 分担一些计算的压力. 从客户端来说,JavaScript是一门弱类型语言 ...
- 洛谷P4241 采摘毒瘤
传送门 完了我连背包都不会了…… 考虑暴力,先枚举最小的数是哪个,设大小为$d_i$,个数为$k_i$,所有比它小的数的总和是$sum$,然后把所有比它小的全都装进背包,它以及比他大的做一个多重背包, ...
- javascript实现继承的4种方法,以及它们的优缺点
1. 原型链继承(有缺陷): 缺陷1:切断了Zi.prototype.constructor与Zi的关系 缺陷2:原型链上的引用类型的数据会被所有实例共享 2. 构造函数继承(有缺陷): 缺陷1:Fu ...
- css 实现 checkbox 大小调整
一般调整 checkbox 大小我们想到的是 width.height,可是设置后,发现是没有效的. 如微信小程序里面,checkbox 默认就很大,想设置小一点怎么办? transform: sca ...
- LOJ#557. 「Antileaf's Round」你这衣服租来的吗(FHQ Treap+珂朵莉树)
题面 传送门 题解 好吧我是不太会复杂度分析-- 我们对于每种颜色用一个数据结构维护(比方说线段树或者平衡树,代码里写的平衡树),那么区间询问很容易就可以解决了 所以现在的问题是区间修改,如果区间颜色 ...
- DHTML_____window对象方法
<html> <head> <meta charset="utf-8"> <title>window对象方法</title&g ...
- [转]T4系列文章之3:T4语法的介绍
本文转自:http://www.cnblogs.com/damonlan/archive/2012/03/06/2382724.html 因为这段时间一直都没空,我也不知道有没有对人T4感兴趣,但不管 ...
- 生成清除某个数据库下的所有表的SQL语句
方法1:重建库和表 用mysqldump --no-data把建表SQL导出来,然后drop database再create database,执行一下导出的SQL文件: 方法2:生成清空所有表的SQ ...
- [转] Redis在windows下安装过程
转载自(http://www.cnblogs.com/M-LittleBird/p/5902850.html) 一.下载windows版本的Redis 去官网找了很久,发现原来在官网上可以下载的win ...
- sublime text3 =个人插件
1.sublime text3汉化插件安装. ctrl+shift+p → Package Control:Install Package → ChineseLocalization preferen ...