POJ4852 Ants
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 20047 | Accepted: 8330 |
Description
Input
Output
Sample Input
2
10 3
2 6 7
214 7
11 12 7 13 176 23 191
Sample Output
4 8
38 207
Source
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define abs(a) ((a) < 0 ? (-1 * (a)) : (a)) const int MAXN = + ;
const int INF = 0x3f3f3f3f; inline void read(int &x)
{
x = ;char ch = getchar(), c = ch;
while(ch < '' || ch > '')c = ch, ch = getchar();
while(ch <= '' && ch >= '')x = x * + ch - '', ch = getchar();
} int t,n,l,num,ma,mi; int main()
{
read(t);
for(;t;--t)
{
read(l);read(n);
mi = ma = ;
for(register int i = ;i <= n;++ i)
{
read(num);
mi = max(mi, min(num, l - num));
ma = max(ma, max(num, l - num));
}
printf("%d %d\n", mi, ma);
}
return ;
}
POJ4852
POJ4852 Ants的更多相关文章
- 使用ANTS Performance Profiler&ANTS Memory Profiler工具分析IIS进程内存和CPU占用过高问题
一.前言 最近一段时间,网站经常出现两个问题: 1.内存占用率一点点增高,直到将服务器内存占满. 2.访问某个页面时,页面响应过慢,CPU居高不下. 初步判断内存一点点增多可能是因为有未释放的资源一直 ...
- poj1852 Ants ——想法题、水题
求最短时间和最长时间. 当两个蚂蚁相遇的时候,可以看做两个蚂蚁穿过,对结果没有影响.O(N)的复杂度 c++版: #include <cstdio> #define min(a, b) ( ...
- Uva10881 Piotr's Ants
蚂蚁相撞会各自回头.←可以等效成对穿而过,这样移动距离就很好算了. 末状态蚂蚁的顺序和初状态其实是相同的. 那么剩下的就是记录每只蚂蚁的标号,模拟即可. /*by SilverN*/ #include ...
- [ACM_模拟] UVA 10881 Piotr's Ants[蚂蚁移动 数组映射 排序技巧]
"One thing is for certain: there is no stopping them;the ants will soon be here. And I, for one ...
- .NET性能调优之一:ANTS Performance Profiler的使用
.NET性能调优系列文章 系列文章索引 .NET性能调优之一:ANTS Performance Profiler的使用 .NET性能调优之二:使用Visual Studio进行代码度量 .NET性能调 ...
- [CareerCup] 7.2 Ants on Polygon 多边形上的蚂蚁
7.2 There are three ants on different vertices of a triangle. What is the probability of collision ( ...
- Uva---10881 Piotr's Ants(蚂蚁)
Problem DPiotr's AntsTime Limit: 2 seconds "One thing is for certain: there is no stopping them ...
- Educational Codeforces Round 7 E. Ants in Leaves 贪心
E. Ants in Leaves 题目连接: http://www.codeforces.com/contest/622/problem/E Description Tree is a connec ...
- Codeforces Round #188 (Div. 1) B. Ants 暴力
B. Ants Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/317/problem/B Des ...
随机推荐
- 关于iosselectjs插件设置同步值的操作实践
关于移动端选择器的插件选择百度可以搜到很多,之前用过iosselect.js(https://github.com/zhoushengmufc/iosselect)感觉还不错,比mobiscorll. ...
- kafka集群搭建文档
kafka集群搭建文档 一. 下载解压 从官网下载Kafka,下载地址http://kafka.apache.org/downloads.html 注意这里最好下载scala2.10版本的kafka, ...
- [POI2017]Sabota【观察+树形Dp】
Online Judge:Bzoj4726 Label:观察,树形Dp,水题 题目描述 某个公司有n个人, 上下级关系构成了一个有根树.公司中出了个叛徒(这个人不知道是谁). 对于一个人, 如果他下属 ...
- boost 字符串大小写转换
示例代码如下: #include <boost/algorithm/algorithm.hpp> #include <iostream> using namespace std ...
- locate,find,df,mount,du命令
1.locate找数据的时候,相当于去这个数据库里面查(locate查找的时候不扫描磁盘)查找图标文件:locate .icolocat -i 不区分大小写创建一个文件,该文件没有在数据库中,要想在数 ...
- 【bzoj2120】数颜色 带修莫队
数颜色 题目描述 墨墨购买了一套N支彩色画笔(其中有些颜色可能相同),摆成一排,你需要回答墨墨的提问.墨墨会像你发布如下指令: 1. Q L R代表询问你从第L支画笔到第R支画笔中共有几种不同颜色的画 ...
- Creating a bootable Ubuntu USB stick
Windows: https://tutorials.ubuntu.com/tutorial/tutorial-create-a-usb-stick-on-windows#0 Ubuntu: http ...
- Ionic 包名修改 步骤
1.config.xml => <widget id=...... 2.plugin 中 android.json 里面package 3.platforms\android 里面 and ...
- 软件-MQ-RabbitMQ:RabbitMQ
ylbtech-软件-MQ-RabbitMQ:RabbitMQ RabbitMQ是实现了高级消息队列协议(AMQP)的开源消息代理软件(亦称面向消息的中间件).RabbitMQ服务器是用Erlang语 ...
- centos7 盘符变动 绑定槽位
服务器下的硬盘主有机械硬盘.固态硬盘以及raid阵列,通常内核分配盘符的顺序是/dev/sda./dev/sdb… ….在系统启动过程中,内核会按照扫描到硬盘的顺序分配盘符(先分配直通的,再分配阵列) ...