【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 ...
随机推荐
- MySQL5.6 windows msi安装介绍
200 ? "200px" : this.width)!important;} --> 一.功能介绍 1.MySQL Servers 该功能是mysql主要的服务,也是必须安 ...
- 关于Java泛型的?和 T 的区别
java中的?号指未知的类型:而T指具体类型 泛型问号(?)未知的类型就是可以指定当前问号(?)所代表的类,可以指定上限(extends)和下限(super) 泛型T指已经具体知道了类型,就是不能指定 ...
- bzoj 1026: [SCOI2009]windy数【数位dp】
忘记limit不能记WA了一发-- 典型数位dp,变成work(r)-work(l-1),然后dfs的时候记录w当前位置,la上一个数选的什么,lm当前位是否有上限,ok当前位是否可以不考虑差大于等于 ...
- ATX 学习 (三)-atxserver2-android-provider
服务端代码 代码clone到本地,搭好相应环境(怎么搭的这里就不介绍了,很好搭的哈)一般库首先查看main.py文件,debug模式开始运行 一开始就是没接触过的tornado.ioloop,有点偏底 ...
- 洛谷 P1045 麦森数
题目描述 形如2^{P}-1的素数称为麦森数,这时P一定也是个素数.但反过来不一定,即如果P是个素数,2^{P}-1不一定也是素数.到1998年底,人们已找到了37个麦森数.最大的一个是P=30213 ...
- 整数类型c++
数据类型 定义标识符 占字节数 数值范围 数值范围 短整型 short [int] 2(16位) -32768-32767 -215-215-1 整型 [long] int 4(32位) -21474 ...
- Hdu 4612 Warm up (双连通分支+树的直径)
题目链接: Hdu 4612 Warm up 题目描述: 给一个无向连通图,问加上一条边后,桥的数目最少会有几个? 解题思路: 题目描述很清楚,题目也很裸,就是一眼看穿怎么做的,先求出来双连通分量,然 ...
- python做一个数独小游戏
最近看了下python的一些知识,在这里记载一下. 1.首先是安装,在官网下载最新的版本3.6,安装的时候要注意在下面勾选上ADD TO PATH,安装的时候会自动写入到环境变量里面,如果没有勾选,可 ...
- 安装ipython notebook及基本命令(快捷键)
转载自:http://121.42.47.99/yuenshome/wordpress/?p=2622 目前基本上是Pycharm和ipython notebook结合起来做东西,ipython no ...
- struts2配置文件加载顺序
struts2配置文件加载顺序: struts-default.xml/ struts-plugin.xml/ struts.xml/ struts.properties/ web.xml