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. SpringMVC05 return (Json)

    这里要主要的是js文件要引入,文中不做解释 1.导入包 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xs ...

  2. JSTL,JQuery,Ajax,Json

    JSTL 的定义  1  JSP 标准标签库 (JavaServerPage Standard Tag Library) 2  JSTL 通常会与EL 表达式合作实现JSP页面的编码   JSTL 的 ...

  3. 使用random函数实现randint函数的功能

    首先说明一下 random函数是random模块中的一个函数 首先要导入random模块 import random random函数的功能 #生成某一范围(0-1)内的随机小数print(rando ...

  4. 父类和子类以及super关键字

    super和this关键字的特点类似:super代表的是父类对象的引用. 当子父类的成员出现同名时,可以通过super来进行区分. 子类的构造方法中,通过super关键字调用父类的构造方法. publ ...

  5. Callable的简单使用

    说起java的线程操作,都会想到Thread和Runable这两个, 这两个类可以实现异步和同步. 在大多数的java开发中, 这两个都是实现异步的线程来使用, 但是现在考虑一种情况: 发出一条线程, ...

  6. System Center Configuration Manager 2016 必要条件准备篇(Part1)

    步骤4.创建系统管理容器 SCCM 2016 配置管理系列(Part 1- 4) 介绍AD01上配置了Active Directory域服务(ADDS),然后将Configuration Manag ...

  7. Python基础总结与实践

    Python简介 Python是一种动态解释型编程语言,在模块载入时将源码编译成字节码, 这些字节码被虚拟机PVM解释执行,其中解释执行是Python性能较低的主要原因: Python使用C语言编写, ...

  8. IOS 绘制基本图形( 画圆、画线、画圆弧、绘制三角形、绘制四边形)

    // 当自定义view第一次显示出来的时候就会调用drawRect方法- (void)drawRect:(CGRect)rect { // 1.获取上下文 CGContextRef ctx = UIG ...

  9. fflush - 刷新一个流

    SYNOPSIS 总览 #include <stdio.h> int fflush(FILE *stream); DESCRIPTION 描述 函数 fflush 强制在所给的输出流或更新 ...

  10. python_68_迭代器

    ''' 我们已经知道,可以直接作用于for循环的数据类型有以下几种: 一类是集合数据类型,如list.tuple.dict.set.str等: 一类是generator,包括生成器和带yield的ge ...