题目求的是:所有蚂蚁用最短时间从木棍上走下来的最大值(也就是最后一个蚂蚁什么时候走下来的)

      所有蚂蚁中,用时最长的情况

PS:根本不用考虑两只蚂蚁相遇又折返的情况(可以直接认为是他两互不影响的走)

 #include <iostream>

 using namespace std;

 int main()
{
int t;
cin >> t;
while(t--)
{
int len, ants, sum = ;
int min_t = , max_t = ;
cin >> len >> ants;
int length;
for(int i = ; i <= ants; i++)
{
cin >> length;
min_t = max(min_t, min(length, len-length));///停留在木棒上,可能用的最短时间的最大值
max_t = max(max_t, max(length, len-length));///可能的最大时间的最大值
} cout << min_t << " " << max_t << endl;
}
return ;
}

Poj1852的更多相关文章

  1. poj1852 Ants(思维)

    https://vjudge.net/problem/POJ-1852 最短时间显然是各自往靠近端点的地方走. 最长时间关键是要想到,折返和擦肩其实是一样的,可以当成两只蚂蚁换了个位子,最终求max是 ...

  2. poj1852 Ants ——想法题、水题

    求最短时间和最长时间. 当两个蚂蚁相遇的时候,可以看做两个蚂蚁穿过,对结果没有影响.O(N)的复杂度 c++版: #include <cstdio> #define min(a, b) ( ...

  3. [POJ1852]Ants

    Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 12431   Accepted: 5462 Description An a ...

  4. 思维水题 poj1852

    题目链接:http://poj.org/problem?id=1852 题意:木板长为n,    蚂蚁数量为k,    后面k个数,依次代表蚂蚁的位置,  当蚂蚁到达边界的时候会立马掉下,当两个蚂蚁相 ...

  5. 《挑战程序设计竞赛》1.6 轻松热身 POJ1852

    Ants Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 12782   Accepted: 5596 Description ...

  6. POJ1852 Ants 题解

    题目 An army of ants walk on a horizontal pole of length l cm, each with a constant speed of 1 cm/s. W ...

  7. [POJ1852] Ants(思维题)

    题干 An army of ants walk on a horizontal pole of length l cm, each with a constant speed of 1 cm/s. W ...

  8. [POJ3684]Physics Experiment

      Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1363   Accepted: 476   Special Judge ...

随机推荐

  1. 利用 Rational ClearCase ClearMake 构建高性能的企业级构建环境

    转载地址:http://www.ibm.com/developerworks/cn/rational/r-cn-clearmakebuild/ 构建管理是 IBM® Rational® ClearCa ...

  2. java.util.ConcurrentModificationException

    遍历 List 的时候将 item remove 掉会抛出此异常

  3. 20145206邹京儒《Java程序设计》课程总结

    20145206邹京儒<Java程序设计>课程总结 (按顺序)每周读书笔记链接汇总 第一周:http://www.cnblogs.com/ZouJR/p/5213572.html http ...

  4. .net学习笔记---webconfig的读与写

    System.ConfigurationManager类用于对配置文件的读取.其具有的成员如下: 一.AppSettings AppSetting是最简单的配置节,读写非常简单. 名称 说明 AppS ...

  5. 19.状态者模式(State Pattern)

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  6. asmlinkage

    转自:http://www.cnblogs.com/china_blue/archive/2010/01/15/1648523.html 声明,仅为了便于自己记忆和查询,非原创,摘自:http://b ...

  7. ASP.NET Web Api 安全性(转载)

    转载地址:http://www.cnblogs.com/fzrain/p/3552423.html 在Web Api中强制使用Https 我们可以在IIS级别配置整个Web Api来强制使用Https ...

  8. Window Server 2003(IIS6) 安装.net4.0遇到的问题总结

    1.Window server 2003系统原本就装了.net1.0..net2.0 ,安装.net 4.0之前,系统已经发不了一些网站,这个时候,我安装.net 4.0返现程序不能访问了,提示ser ...

  9. 【翻译十九】-java之执行器

    Executors In all of the previous examples, there's a close connection between the task being done by ...

  10. C# 非UI线程对控件的控制

    第一步:定义委托 public delegate void wei(string ss); 第二步:控制UI的方法 public void get1(string ss) { richTextBox1 ...