192B Walking in the Rain
2012-07-13 22:37
267 查看
简单DP,设 f[i] 为到达第 i 个位置最迟的天数,那么 f[i] 为 min(f[i-2], a[i]) 和 min(f[i-1], a[i]) 中的较大者;
# include <cstdio> # include <algorithm> # define N 1005 using namespace std; int n, a ; int f ; void init(void) { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &a[i]); } void solve(void) { f[1] = a[1], f[2] = min(f[1], a[2]); for (int i = 3; i <= n; ++i) { f[i] = max(min(f[i-2], a[i]), min(f[i-1], a[i])); } printf("%d\n", f ); } int main() { init(); solve(); return 0; }
相关文章推荐
- sunshine in the rain
- ACdream 1079 Walking in the Rain (线性dp)
- <cf>Walking in the Rain
- ZOJ-3923-In the Rain
- <cf>Walking in the Rain
- Could not load the "light_rain.png" image referenced from a nib in the bundle with identifier
- 【ZOJ3921 2016年浙大2月月赛I】【物理题 底乘高积分式思维】In the Rain 圆柱体人行走 吸收雨体积
- 经典英文老歌——《雨中曲(singin' in the rain)》+ 胖狗狗的雨中曲速写 ^_^
- 经典英文老歌——《雨中曲(singin' in the rain)》+ 胖狗狗的雨中曲速写 ^_^
- 雨巷(A Lane in the Rain)
- [英语歌曲]Sunshine In The Rain
- zoj-3923- In the Rain
- ZOJ 3923 In the Rain(数学)
- The markup in the document preceding the root element must be well-formed
- How to fix the issue that GEM_HOME and/or GEM_PATH not set issue for rvm in mac version 10.12
- How to resolve the truncate/drop/delete/join hang issue in ADW
- pod》error:The dependency `` is not used in any concrete target
- [Python] Finding the most common elements in an iterable
- FAQ(67):java.sql.SQLException: You have an error in your SQL syntax; check the manual that correspon
- 托福写作5-what is the most important characteristic that a person can have to be successful in life