poj1852 Ants
来源:互联网 发布:幼儿园网络研修的简报 编辑:程序博客网 时间:2024/05/17 13:40
//这题的思路十分巧妙,两只蚂蚁同时反方向走,因为所有蚂蚁速度一致,可以看作是没有反向,而是继续按原方向走,直到下落...相当于将每只蚂蚁看作是独立运动的(挑战P20)#include <iostream>using namespace std;const int N = 1e6 + 10;int t, l, n;int a[N];void solve(){int mint = 0, maxt = 0;//min time, max timefor ( int i = 0; i < n; i++ ){mint = max ( mint, min(a[i], l - a[i]) ); //最终求的是所有蚂蚁掉下所用的时间,所以外面取maxmaxt = max ( maxt, max(a[i], l - a[i]) ); }cout << mint << " " << maxt << endl;}int main(){cin >> t;while (t--){cin >> l >> n;for ( int i = 0; i < n; i++ ) cin >> a[i];solve();}return 0;}
阅读全文
0 0
- POJ1852(Ants)
- poj1852 Ants
- poj1852 Ants
- POJ1852 Ants
- POJ1852 Ants
- POJ1852-Ants
- poj1852(Ants)
- POJ1852 Ants
- POj1852--Ants
- POJ1852 Ants
- 【poj1852】Ants
- poj1852 Ants
- POJ1852 Ants
- POJ1852 Ants
- POJ1852-Ants
- poj1852 Ants
- poj1852 Ants
- ZOJ2376 POJ1852 Ants,贪心
- C#基础-006(1)if练习题 判断一个数是不是偶数,如果是偶数那么就加1并打印
- url 映射 3种匹配方法
- ImageLoader获取磁盘中存入的图片
- L
- 【DP】回文的最小分割数
- poj1852 Ants
- C 语言各个数据类型所占字节数
- oracle中like总结
- poj3617 Best Cow Line
- IIS WebService 内存溢出问题的修改过程
- 【leetcode】38. Count and Say(Python & C++)
- 找出1000以内的完全数。
- spring boot 开发热部署配置 (idea IDE)
- TabLayout使用