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 ...
随机推荐
- Authentication to host '***‘' for user 'root' using method 'mysql_native_password' failed with message: Reading from the stream has failed.
如下场景: 一个页面中需要用户填入文字信息,并上传图片,上传图片是单独调用上传文件接口的,当用户上传图片后,马上点保存,就会报错. Authentication to host '***‘' for ...
- 解决ARCGIS10.2与VS2013不兼容
在注册表中HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0增加类型为REG_SZ的InstallDir节点.Ins ...
- bootstrapTable的数据后端分页排序
数据后端分页排序,其实就是sql语句中oeder by做一些限制. 之前在写sql语句中的order by是写死,既然要写活,就要传参数到后台. 之前讲到bootstrapTable的queryPar ...
- 设置mapcontrol的鼠标样式
http://blog.itpub.net/14999074/viewspace-586515/ mapcontrol的鼠标样式 this.axMapControl1.MousePointer=esr ...
- git 初始化仓库与远程clone
使用命令 git –bare init /home/git/myRep.git,初始化化仓库 在gitClient_01上,通过git clone命令进行克隆远程仓库,并在各自的电脑上运行开发. Gi ...
- cms-幻灯片的实现
1.其实幻灯片的后台代码和之前的最新动态和推荐是一样的,只是前台遍历的时候不一样罢了 2.代码: 2.1:帖子mapper查询出幻灯片图片: <?xml version="1.0&qu ...
- DataView RowFilter
DataView类用来表示定制的DataTable的视图. DataTable和DataView的关系是遵循著名的设计模式--文档/视图模式,其中DataTable是文档,而Dataview是视图. ...
- ubuntu 16.4 安装配置IK6.3.2
1. 从官网下载对应的解析版本 https://github.com/medcl/elasticsearch-analysis-ik/releases/tag/v6.3.2 2. 配置环境 安装mvn ...
- this.value = this.placeholder || this.getAttribute('placeholder')
this.value = this.placeholder || this.getAttribute('placeholder') 鉴于不同的浏览器对为止属性的实现方式有所不用,这里同时使用了HTML ...
- 简析平衡树(一)——替罪羊树 Scapegoat Tree
前言 平衡树在我的心目中,一直都是一个很高深莫测的数据结构.不过,由于最近做的题目的题解中经常出现"平衡树"这三个字,我决定从最简单的替罪羊树开始,好好学习平衡树. 简介 替罪羊树 ...