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. 前端专业术语: shim 和 Polyfill,了解下

    在学习和使用 JavaScript 的时候,我们会经常碰到两个术语:shim 和 polyfill.它们有许多定义和解释,意思相近又有差异. Shim Shim 指的是在一个旧的环境中模拟出一个新 A ...

  2. 你还在为UiPath课程考试发愁吗?

    刚开始学UiPath的时候,课程的考试难倒了很多人,有语言的原因也有对课程理解的原因,记忆中好像有一课考了5次估计,由于题库也就那么多,只要你努力考,总会过的. 学会了RPA的自动化工具,能否自动化答 ...

  3. Java实例学习——企业进销存管理系统(4)

    Java实例学习——企业进销存管理系统(4) (本实例为书上实例,我所记录的是我的学习过程) 开始时间:2月12日 完成时间:暂未完成 2月18日——系统主窗体设计 只看了学习视频 2月19日—— 回 ...

  4. c#异步Begininvoke使用随笔

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  5. spring运用的设计模式

    1.代理模式(典型的aop) 2.工厂模式(beanFactory) 3.观察者模式(ApplicationContextEvent && ApplicationContextList ...

  6. Remote System Explorer Operation在eclipse后台一直跑 解决办法

    在用eclipse开发时,经常遇到卡死的情况,其中一种就是右下角出现:“Remote System Explorer Operation”,解决方案如下: 第一步:Eclipse -> Pref ...

  7. 美国L1签证申请的常见问题解析

    美国L1是一种允许在美国和中国都有机构的跨国公司从国外的母公司派遣一定层次的经理或专业技术人员去美国分支机构工作的非移民签证.L1签证分两类:美国L1A是跨国公司经理及主管人员签证,L1B是专门技术人 ...

  8. shrio中去掉 login;JSESSIONID

    shrio中去掉 login;JSESSIONID 在session管理器配置页面中新增一条记录

  9. ffmpeg 命令2

    ffmpeg常用基本命令(转) [FFmpeg]FFmpeg常用基本命令 1.分离视频音频流 ffmpeg -i input_file -vcodec copy -an output_file_vid ...

  10. SAP云平台运行环境Cloud Foundry和Neo的区别

    SAP云平台提供了两套运行环境:Cloud Foundry和Neo 从下图能发现,Cloud Foundry的运行环境,基础设施由第三方公司提供,比如Amazon亚马逊和Microsoft微软,SAP ...