CTU Open Contest 2017
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的更多相关文章
- Gym - 101670A Amusement Anticipation(CTU Open Contest 2017 签到题)
题目&题意: 倒着找处于最后位置的等差数列的开头的位置. 例: 1 5 3 4 5 6 3 4 5 6是等差数列,它的开头的位置是3 PS: 读题真的很重要!!!!多组输入,上来就读错了!! ...
- Gym - 101670F Shooting Gallery(CTU Open Contest 2017 区间dp)
题目&题意:(有点难读...) 给出一个数字序列,找出一个区间,当删除这个区间中的两个相同的数字后,只保留这两个数字之间的序列,然后继续删除相同的数字,问最多可以实行多少次删除操作. 例如: ...
- Gym - 101670G Ice cream samples(CTU Open Contest 2017 尺取法)
题目: To encourage visitors active movement among the attractions, a circular path with ice cream stan ...
- Gym - 101670E Forest Picture (CTU Open Contest 2017 模拟)
题目: https://cn.vjudge.net/problem/1451310/origin 题意&思路: 纯粹模拟. 大体题意是这样的: 1.有人要在一个10-9<=x<=1 ...
- 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 ...
- 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 ...
- Gym - 101670C Chessboard Dancing(CTU Open Contest 2017 找规律)
题目:链接 思路: 多画出几个情况就可以找出规律来了 Knight (当大于2的时候只要两种颜色相间出现就可以了) King(当大于等于3的时候,总可以用四种形式来补色,具体如下) Bishop(斜 ...
- 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 ...
- Gym - 101670J Punching Power(CTU Open Contest 2017 最大独立集)
题目: The park management finally decided to install some popular boxing machines at various strategic ...
随机推荐
- 工作经验(C++篇)
这篇总结是我正式参加工作后,和同事交流学习得出来的,希望对其他人有帮助,也是自己的脚印 C++编程中,常会使用到类,组长给我们的经验是,一个类写在一个文件中,不要多各类写在一个文件 为了跨平台性,一个 ...
- SpringBoot | 第十四章:基于Docker的简单部署
前言 讲解了单元测试,本章节讲讲应用的部署吧.总体而言,在进行自动化部署时,基本都会用上Jenkins+Maven+Docker进行部署.本章节主要讲解使用Maven+Docker进行SpringBo ...
- SQLServer 索引的使用情况
—在优化查询SQL语句,查看索引使用情况SQL语句: select db_name(database_id) as N'数据库名称', object_name(a.object_id) as N'表名 ...
- 扔掉360:Linux下无线网卡作WiFi路由器(转薄荷开源网)
这个话题很多人感兴趣,毕竟现在是无线互联时代.手机一族到外面去,首先关心的就是有没有 WiFi.Windows 7 用户可以安装 360 的软件,把笔记本电脑配置成路由器,供手机或其他电脑上网. 在 ...
- SpringMVC配置文件 中 mvcview-controller 标签的使用
一.<mvc:view-controller path=""/>标签的作用 工程WEB-INF目录下面的JSP页面,我们知道是不能直接使用URL访问到.需要通过控制器转 ...
- linux下安装redis和部署
转自简书:https://www.jianshu.com/p/bc84b2b71c1c 1.基础知识 redis是用C语言开发的一个开源的高性能键值对(key-value)数据库.它通过提供多种键值 ...
- JVM(二):垃圾回收
三个问题: 那些内存需要回收? -- 对象是否存活判断 什么时候回收? --垃圾回收触发条件 如何回收? --垃圾回收算法 垃圾回收应用 -- 理解GC日志.使用垃圾回收命令和工具 1. 判断 ...
- C#类型简述
一.值类型 1.布尔类型 bool,范围 true false 2.整数类型 sbyte,范围 -128~127 byte,范围 0~255 short,范围 -32768~32767 ushort, ...
- EF中Entity SQL用法
public List<policecase> GetPoliceCaseList(PoliceCaseFilter view) { string sq ...
- SQL Server 08版与14版处理重复行的方式
在项目中,利用循环拼接成了插入多行数据的SQL语句: Insert into table(col1,col2)vaules(value11,value21); Insert into table(co ...