蚂蚁这道题 就是 不管两只蚂蚁相撞  他们会朝自己的反方向走

不过可以这么想  有蚂蚁1 和 蚂蚁2   并且相向而行

如果撞了以后 蚂蚁1和蚂蚁2 就往回走   ,这里可以理解成蚂蚁1,蚂蚁2 继续朝自己的方向走

因为我们是不关心 具体蚂蚁的到达哪个端点的

#include <bits/stdc++.h>
using namespace std; int main ()
{
int n,L;
cin >> n >> L;
int ans1= ,ans2=;
for(int i=;i<=n;i++)
{
int x;cin >> x;
int mx = min(x,L-x);
int Mx = max(x,L-x);
ans2 = max(Mx,ans2);
ans1 = max(mx,ans1);
}
cout << ans1<<" "<<ans2<<endl; }

51nod 1266 蚂蚁的更多相关文章

  1. 【51Nod 1244】莫比乌斯函数之和

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1244 模板题... 杜教筛和基于质因子分解的筛法都写了一下模板. 杜教筛 ...

  2. 51Nod 1268 和为K的组合

    51Nod  1268  和为K的组合 1268 和为K的组合 基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 给出N个正整数组成的数组A,求能否从中选出若干个,使 ...

  3. 51Nod 1428 活动安排问题

    51Nod   1428  活动安排问题 Link: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1428 1428 活 ...

  4. 51Nod 1278 相离的圆

    51Nod 1278 相离的圆 Link: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1278 1278 相离的圆 基 ...

  5. 【51Nod 1501】【算法马拉松 19D】石头剪刀布威力加强版

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1501 dp求出环状不连续的前缀和,剩下东西都可以算出来,比较繁琐. 时间 ...

  6. 【51Nod 1622】【算法马拉松 19C】集合对

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1622 简单题..直接暴力快速幂 #include<cstdio&g ...

  7. 【51Nod 1616】【算法马拉松 19B】最小集合

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1616 这道题主要是查询一个数是不是原有集合的一个子集的所有数的gcd. ...

  8. 【51Nod 1674】【算法马拉松 19A】区间的价值 V2

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1674 对区间分治,统计\([l,r]\)中经过mid的区间的答案. 我的 ...

  9. poj 1266 Cover an Arc.

    http://poj.org/problem?id=1266 Cover an Arc. Time Limit: 1000MS   Memory Limit: 10000K Total Submiss ...

随机推荐

  1. python基础班-淘宝-目录.txt

    卷 TOSHIBA EXT 的文件夹 PATH 列表卷序列号为 AE86-8E8DF:.│ python基础班-淘宝-目录.txt│ ├─1-1 Linux基础│ ├─01-课程简介│ │ 01-课程 ...

  2. android 网络监测

    public class NetWorkStateReceiver extends BroadcastReceiver { @Override public void onReceive(Contex ...

  3. 3.cassandra遇到内存占用过高的问题

    目前cssandra的内存分配如下: https://docs.datastax.com/en/cassandra/2.1/cassandra/operations/ops_tune_jvm_c.ht ...

  4. [py]字符串/列表

    去除str首尾空格(切片) ## str长度 循环,判断 ### [:i] [i:] 记录位置点 ## 方法1 def trim2(s): s2 = "" start = 0 en ...

  5. df值自由度学习[转载]

    转自:https://www.applysquare.com/topic-cn/78TAnIzZ6/ https://zhidao.baidu.com/question/175605082855699 ...

  6. Java接口多线程并发测试 (一)

    本文为作者原创,禁止转载,违者必究法律责任!!! 本文为作者原创,禁止转载,违者必究法律责任!!! Java接口多线程并发测试 一,首先写一个接口post 请求代码: import org.apach ...

  7. #C语言初学记录(位运算)

    位运算 Problem Description7-1 数组元素循环右移问题 一个数组A中存有N(>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(≥0)个位置,即将A中的数据由 ...

  8. sql 查询不存在左表的数据

    select * from zyz_mgr_wlcyiduifu a left join WLCInformation b ona.wlcId=b.WLCInvestorApplyID where b ...

  9. Yosemite安装libv8和therubyracer

    yosemite ruby version升级的时候,会碰到类似 Make sure that `gem install libv8 -v '3.16.14.3'` succeeds before b ...

  10. VS2010/MFC编程入门之四十七(字体和文本输出:CFont字体类)

    上一节中鸡啄米讲了MFC异常处理,本节的主要内容是字体CFont类. 字体简介 GDI(Graphics Device Interface),图形设备接口,是Windows提供的一些函数和结构,用于在 ...