UVa 12032 - The Monkey and the Oiled Bamboo
来源:互联网 发布:mac 装win10 鼠标右键 编辑:程序博客网 时间:2024/06/06 05:48
題目:有一個梯子,從0層(地上)跳到頂上,梯子上面有一些位置要經過, 設置一個步長k層,
每次跳躍可以是k層或者是小於k的層數,如果跳了k層,則k就減少1,求最小的k。
分析:模擬,貪心。直接逆向求解,每次遇到更大的或者相同的更新即可。
說明:╮(╯▽╰)╭。
#include <cstring>#include <cstdio>int r[100001] = {0};int main(){int T, n;while (~scanf("%d",&T))for (int t = 1; t <= T; ++ t) {scanf("%d",&n);for (int i = 1; i <= n; ++ i) {scanf("%d",&r[i]);}int ans = r[n]-r[n-1];for (int i = n-1; i > 0; -- i) {if (ans < r[i]-r[i-1]) {ans = r[i]-r[i-1];}else if (ans == r[i]-r[i-1]) {ans = r[i]-r[i-1]+1;}}printf("Case %d: %d\n",t,ans);}return 0;}
0 0
- UVa 12032 - The Monkey and the Oiled Bamboo
- UVa12032 - The Monkey and the Oiled Bamboo(贪心)
- LightOJ - 1425 The Monkey and the Oiled Bamboo(贪心)
- lightoj 1425 - The Monkey and the Oiled Bamboo
- LightOJ - 1425 The Monkey and the Oiled Bamboo (水)
- lightoj 1425 - The Monkey and the Oiled Bamboo 二分答案or乱搞
- UVA - 12074 The Ultimate Bamboo Eater 二维线段树
- Enjoy everyday and don't be the Monkey
- hdu 1069-Monkey And Banana(The Tower of Babylon)
- Monkey off the back
- poj-openjudge 1040:Bamboo Forest of the Lost 解题报告
- LA 3294 The Ultimate Bamboo Eater (线段树套Treap)
- UVA 168 - Theseus and the Minotaur
- UVa 243 - Theseus and the Minotaur (II)
- UVa 913 - Joana and the Odd Numbers
- Killing the Monkey in the Middle
- HDU 5201 The Monkey King
- HDU 5201 The Monkey King
- C#单链表
- hdu 4125 二叉搜索树建立与kmp
- 第十六周项目一 a阅读程序(2)
- C++:const和sizeof
- Linux - top命令
- UVa 12032 - The Monkey and the Oiled Bamboo
- template中 class和typename的区别
- JavaScript学习笔记之循环在遍历数组的简单使用
- Fragment简介
- 向量几何在游戏编程中的使用1
- 《Java程序设计》课程实验指导书程序代码(答案)(实验七)
- hdu 4123 rmq与树的直径
- pixhawk 整体架构的认识
- 一些算法总结