杭电OJ 1008
2018-03-06 16:32
281 查看
很简单的一道题,代码如下://杭电oj 1008 张艺川 2018/3/6
#include<iostream>
using namespace std;
int main(){
int N;//N次楼层请求
int upStairs = 6;//上楼需要6s
int downStairs = -4;//下楼需要4s
int stay = 5;//每一次停留需要5秒
while (cin >> N && N != 0){
int current = 0;//当前楼层
int next = 0;//下一个请求的楼层
int total = 0;//总时间
int difference = 0;//楼层的差值
for (int i = 0; i < N; i++){
cin >> next;
difference = next - current;
if (difference>0){
total += difference*upStairs;
}
else{
total += difference*downStairs;
}
total += stay;
current = next;
}
cout << total<< endl ;
}
}
相关文章推荐
- 杭电oj -1008
- 杭电oj 1008
- 杭电OJ 1008 应该全面考虑问题
- 【杭电-oj】-1008-Elevator(电梯)
- 杭电OJ1008-电梯Elevator
- 杭电oj1008电梯
- 杭电Oj 1004 1005 1008心得
- 杭电oj1879 继续畅通工程
- 杭电OJ1048-The Hardest Problem Ever
- 【杭电-oj】-1862-EXCEL排序(结构体)
- 【杭电oj】1995 - 汉诺塔V(思维,递归)
- 【杭电-oj】-4548-美素数(打表)
- xxx定律(杭电oj3782)
- 杭电oj2001题解
- 【杭电oj】1028 - Ignatius and the Princess III(母函数打表)
- 最短路(杭电oj2544)(迪杰斯特拉)
- 杭电oj 1004 Let the Balloon Rise
- 杭电OJ---1003
- 杭电oj(java版)——1092 A+B for Input-Output Practice (IV)
- 【杭电OJ】Problem-2004 成绩转换题析坑点