B - Pond Cascade

优先队列维护这个水池需要多少时间 或者 直接扫一遍。

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 100000 + 10;
const int INF = 2e9; LL a[maxn], sum[maxn]; int main()
{
int n;
LL flow;
while(~scanf("%d%lld", &n, &flow))
{
for (int i = 1; i <= n; i++) scanf("%lld", &a[i]); double t1 = INF, sum1 = 0, t2 = -INF, sum2 = 0;
for (int i = n; i >= 1; i--)
sum1 += a[i], t1 = min(t1, sum1*1.0/(n-i+1)/flow);
for (int i = 1; i <= n; i++)
sum2 += a[i], t2 = max(t2, sum2*1.0/i/flow); printf("%.8lf %.8lf\n", t1, t2);
}
}

D - Equinox Roller Coaster

N个点,找出一个可以构成的最大的正方形,并且正方形的边都与坐标轴平行。

对于每个X/Y坐标建一个表。对于每个点,枚举它X/Y坐标对应的表中所有的点(选size较小的那一维),然后判断剩下的另外两个点是否存在。

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
const int maxn = 100000 + 100;
map<int, set<int> > px, py;
int x[maxn], y[maxn]; int main()
{
int n;
while(~scanf("%d", &n))
{
px.clear(), py.clear();
for (int i = 1; i <= n; i++)
{
scanf("%d%d", &x[i], &y[i]);
px[x[i]].insert(y[i]), py[y[i]].insert(x[i]);
} int ans = 0;
for (int i = 1; i <= n; i++)
{
if (px[x[i]].size() < py[y[i]].size())
for (auto j = px[x[i]].begin(); j != px[x[i]].end(); j++)
{
if ((*j) == y[i]) continue;
int dis = (*j) - y[i];
if (px[x[i] + dis].count(y[i]) && px[x[i] + dis].count(*j))
ans = max(ans, dis);
}
else
for (auto j = py[y[i]].begin(); j != py[y[i]].end(); j++)
{
if ((*j) == x[i]) continue;
int dis = (*j) - x[i];
if (py[y[i] + dis].count(x[i]) && py[y[i] + dis].count(*j))
ans = max(ans, dis);
}
}
printf("%d\n", ans);
}
}

CTU Open Contest 2017的更多相关文章

  1. Gym - 101670A Amusement Anticipation(CTU Open Contest 2017 签到题)

    题目&题意: 倒着找处于最后位置的等差数列的开头的位置. 例: 1 5 3 4 5 6 3 4 5 6是等差数列,它的开头的位置是3 PS: 读题真的很重要!!!!多组输入,上来就读错了!! ...

  2. Gym - 101670F Shooting Gallery(CTU Open Contest 2017 区间dp)

    题目&题意:(有点难读...) 给出一个数字序列,找出一个区间,当删除这个区间中的两个相同的数字后,只保留这两个数字之间的序列,然后继续删除相同的数字,问最多可以实行多少次删除操作. 例如: ...

  3. Gym - 101670G Ice cream samples(CTU Open Contest 2017 尺取法)

    题目: To encourage visitors active movement among the attractions, a circular path with ice cream stan ...

  4. Gym - 101670E Forest Picture (CTU Open Contest 2017 模拟)

    题目: https://cn.vjudge.net/problem/1451310/origin 题意&思路: 纯粹模拟. 大体题意是这样的: 1.有人要在一个10-9<=x<=1 ...

  5. Gym - 101670H Go Northwest!(CTU Open Contest 2017 思维题+map)

    题目: Go Northwest! is a game usually played in the park main hall when occasional rainy weather disco ...

  6. Gym - 101670H Dark Ride with Monsters(CTU Open Contest 2017 贪心)

    题目: A narrow gauge train drives the visitors through the sequence of chambers in the Dark Ride attra ...

  7. Gym - 101670C Chessboard Dancing(CTU Open Contest 2017 找规律)

    题目:链接 思路: 多画出几个情况就可以找出规律来了 Knight (当大于2的时候只要两种颜色相间出现就可以了) King(当大于等于3的时候,总可以用四种形式来补色,具体如下)  Bishop(斜 ...

  8. 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 ...

  9. Gym - 101670J Punching Power(CTU Open Contest 2017 最大独立集)

    题目: The park management finally decided to install some popular boxing machines at various strategic ...

随机推荐

  1. Maven的学习资料收集--(一)环境搭建

    这几天在做项目的时候用到了maven,但是自己没有从来没有接触过,所以咋网上找资料,终于找到了一下的资料,这个是别人总结的,我只是转载过来积累.请尊重原创. 官网地址:http://maven.apa ...

  2. Oracle 取上周一到周末的sql

    -- 这样取的是 在一周内第几天,是以周日为开始的 select to_char(to_date('20131005','yyyymmdd'),'d') from dual; --结果:7 注释:20 ...

  3. IE浏览器与非IE浏览器JS日期兼容性问题处理

    执行语句 console.log(new Date("2017-07-04 18:40").getTime()); 在IE浏览器中打印出:NAN 在非IE浏览器中打印出:14991 ...

  4. win7,docker安装后,创建虚拟机分配不了ip错误 err: exit status 255

    问题 win7装docker真麻烦,不如家里的win10爽.另外明明这是个很简单的操作,但是国内的解决方法有点落后,所以我写了个傻瓜式的. 有兴趣的可以直接看issue https://github. ...

  5. JSP对象和JavaBean

    1. JSP 客户端请求 当浏览器请求一个网页时,它会向网络服务器发送一系列不能被直接读取的信息,因为这些信息是作为HTTP信息头的一部分来传送的,如下图所示: Http请求头对应的内容如下: 对应方 ...

  6. fish 常用主题推荐

    在安装fish的前提下 omf install zish omf theme zish zish

  7. C++ vector容器类型的用法及注意

    转自http://www.cnblogs.com/charley_yang/archive/2010/12/11/1903040.html vector类为内置数组提供了一种替代表示,与string类 ...

  8. Hybris UI的Route(路由)实现

    登录Hybris前台,在product catalog里选择Digital camera: 点击某个产品进入明细页面: 注意产品明细这个url: 这个明细页面的路由和SAP UI5的路由思路很像. 在 ...

  9. IOS 图片剪切(封装数据)

    封装 :生成头像(UIImage (NJ).h / .m @interface UIImage (NJ) /** * 生成头像 * * @param icon 头像图片名称 * @param bord ...

  10. iOS 不同的崩溃类型

    http://m.blog.csdn.net/kangguang/article/details/62501490 用汇编语言编写的软件跟用脚本或标记语言编写的Web应用的差别在于,前者在出现问题时会 ...