Pond Cascade Gym - 101670B 贪心+数学
题目:题目链接
思路:题目让求最下面池子满的时间和所有池子满的时间,首先我们考虑所有池子满的时间,我们从上到下考虑,因为某些池子满了之后溢出只能往下溢水,考虑当前池子如果注满时间最长,那么从第一个池子到当前池子容量之和与流速之和之比是一样的,随着数据读入处理一遍即可得出最大的注满时间,即注满全部池子的时间,接下来我们考虑最下方池子的注满时间,这个时间不会大于单独给这个池子注满的时间,同样的,不会大于给最下方池子和他上面那一个池子一块拿出来后最下方池子的注满时间,反着扫描一遍,就可以得出结果。
AC代码:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set> #define FRER() freopen("in.txt", "r", stdin);
#define INF 0x3f3f3f3f using namespace std; int main()
{
//FRER()
int n, num[];
double m, minans, sumans, sum, sumv;
while(~scanf("%d %lf", &n, &m)) {
scanf("%d", &num[]);
sum = 1.0 * num[];
sumv = m;
sumans = sum / sumv;
for(int i = ; i < n; ++i) {
scanf("%d", &num[i]);
sum += 1.0 * num[i];
sumv += m;
sumans = max(sumans, sum / sumv);
}
sum = 1.0 * num[n - ];
sumv = m;
minans = sum / sumv;
for(int i = n - ; ~i; --i) {
sum += 1.0 * num[i];
sumv += m;
minans = min(minans, sum / sumv);
}
printf("%.8f %.8f\n", minans, sumans);
}
return ;
}
Pond Cascade Gym - 101670B 贪心+数学的更多相关文章
- 贪心/数学 Codeforces Round #212 (Div. 2) A. Two Semiknights Meet
题目传送门 /* 贪心/数学:还以为是BFS,其实x1 + 4 * k = x2, y1 + 4 * l = y2 */ #include <cstdio> #include <al ...
- Gym - 101670B Pond Cascade(CTU Open Contest 2017 贪心,二分)
题目: The cascade of water slides has been installed in the park recently and it has to be tested. The ...
- hdu-5695 Gym Class(贪心+拓扑排序)
题目链接: Gym Class Time Limit: 6000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- 洛谷3月月赛div2 题解(模拟+数学+贪心+数学)
由于本人太蒻了,div1的没有参加,胡乱写了写div2的代码就赶过来了. T1 苏联人 题目背景 题目名称是吸引你点进来的. 这是一道正常的题,和苏联没有任何关系. 题目描述 你在打 EE Round ...
- Codeforces Round #330 (Div. 1) A. Warrior and Archer 贪心 数学
A. Warrior and Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/594 ...
- HDU 5965 Gym Class 贪心+toposort
分析:就是给一些拓补关系,然后求最大分数,所以贪心,大的越靠前越好,小的越靠后越好 剩下的就是toposort,当然由于贪心,所以使用优先队列 #include <iostream> #i ...
- Codeforces Round #300(A.【字符串,多方法】,B.【思维题】,C.【贪心,数学】)
A. Cutting Banner time limit per test:2 seconds memory limit per test:256 megabytes input:standard i ...
- Ice Cream Tower Gym - 101194D (贪心 + 二分 )
题目链接 : https://cn.vjudge.net/problem/Gym-101194D 题目大意 : 给你n个冰激凌球,让你用这些冰激凌球去垒冰激凌,要求是下面的这一个必须是他上面一个的两倍 ...
- Codeforces Gym 100269G Garage 数学
Garage 题目连接: http://codeforces.com/gym/100269/attachments Description Wow! What a lucky day! Your co ...
随机推荐
- dtexec命令执行SSIS包
默认情况下,同时安装了 64 位和 32 位版本的 Integration Services 命令提示实用工具的 64 位计算机将在命令提示符处运行 32 位版本.运行 32 位版本的原因是:在 PA ...
- 使用Zeppelin时出现at org.apache.zeppelin.interpreter.thrift.RemoteInterpreterService$Client.recv_getFormType(RemoteInterpreterService.java:288)错误的解决办法(图文详解)
不多说,直接上干货! 问题详解 org.apache.thrift.TApplicationException: Internal error processing getFormType at or ...
- (转载)Python中模块的发布与安装
模块(Module) Python中有一个概念叫做模块(module),这个和C语言中的头文件以及Java中的包很类似,比如在Python中要调用sqrt函数,必须用import关键字引入math这个 ...
- springboot+shiro+cas实现单点登录之shiro端搭建
github:https://github.com/peterowang/shiro-cas 本文如有配置问题,请查看之前的springboot集成shiro的文章 1.配置ehcache缓存,在re ...
- 【extjs6学习笔记】0.1 准备:基础概念(02)
Ext 类 Ext 是一个全局单例的对象,在 Sencha library 中它封装了所有的类和许多实用的方法.许多常用的函数都定义在 Ext 对象里.它还提供了像其他类中一些频繁使用的方法的快速调用 ...
- javaSe-反射2
//创建实体类 package com.java.chap07.sec03; public class Student { private String name; private Integer a ...
- HDU 3001 Travelling (状压DP,3进制)
题意: 给出n<=10个点,有m条边的无向图.问:可以从任意点出发,至多经过同一个点2次,遍历所有点的最小费用? 思路: 本题就是要卡你的内存,由于至多可经过同一个点2次,所以只能用3进制来表示 ...
- C基础的练习集及测试答案(16-30)
16.(课堂)输入一个年份(正整数),判断这年是否是闰年.闰年判断标准:年份能被4整除:如若遇到100的倍数,则需判断年份能否被400整除.(逢4一闰,逢百不闰,逢400又闰) #if 0 .(课堂) ...
- MovieReview—Kingsman THE SECRET SERVICE(王牌特工之特工学院)
Brain Storming Mr. Valentine's Day see excess human beings as the Earth's virus and try to e ...
- ThinkPHP笔记——开启debug调试模式
debug+trace模式可以查看开发过程中TP的错误信息,可以更好地帮助开发者debug.但是debug模式的开启还不是简单的在配置文件中中设置就可以的,经过查资料摸索,找到一种有效的方法. 首先在 ...