麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發設計 > 正文

1008. Elevator (20)

2019-11-11 05:17:18
字體:
來源:轉載
供稿:網友

The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor, and 4 seconds to move down one floor. The elevator will stay for 5 seconds at each stop.

For a given request list, you are to compute the total time spent to fulfill the requests on the list. The elevator is on the 0th floor at the beginning and does not have to return to the ground floor when the requests are fulfilled.

Input Specification:

Each input file contains one test case. Each case contains a positive integer N, followed by N positive numbers. All the numbers in the input are less than 100.

Output Specification:

For each test case, PRint the total time on a single line.

Sample Input: 3 2 3 1 Sample Output: 41

#include<cstdio>const int maxn=110;int a[maxn];int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d",&a[i]); } a[0]=0; int ans=0; for(int i=1;i<=n;i++){ if(a[i]>a[i-1]){ ans+=(a[i]-a[i-1])*6; }else if(a[i]<a[i-1]){ ans+=(a[i-1]-a[i])*4; } } ans+=n*5; printf("%d/n",ans); return 0; }
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: av手机在线免费播放 | 日本不卡视频在线观看 | 久久9色| 激情久久一区二区 | 成年性羞羞视频免费观看 | 在线成人精品视频 | 国产一级做a爱片在线看免 2019天天干夜夜操 | 日韩激情一区 | 巨根插入 | 亚洲精品91 | 日韩美香港a一级毛片免费 日韩激情 | 老师你怎么会在这第2季出现 | 日本高清在线免费 | 久久精品成人免费国产片桃视频 | 亚洲第一页综合 | 免费视频aaa| 一区二区三区四区高清视频 | 久久91精品国产91久久yfo | 成人在线视频精品 | 国产精品99久久久久久董美香 | 色婷婷久久久 | 欧美日韩国产成人在线 | 色999久久久精品人人澡69 | 久色视频网站 | 欧美精品免费一区二区三区 | 国产精品一区2区3区 | 久久在草 | 99热草| 蜜桃网在线 | 久久久一区二区精品 | 国产午夜精品在线 | 免费在线观看成人av | 国产高潮好爽好大受不了了 | 久久精品亚洲欧美日韩精品中文字幕 | 久久超| 久久国产秒 | 美女视频在线观看黄 | 蝌蚪久久窝 | 亚洲va久久久噜噜噜久久男同 | 亚洲福利在线视频 | 久久久久久久久亚洲精品 |