模拟/hdu 1008 Elevator

题意

  开始电梯在0层

  给出n个指令,每个代表下一步停到哪层

  每往上一层需要6秒,往下一层需要4秒,停止需要5秒

  求总时间

分析

  数据很小,模拟即可喵~

Accepted Code

 1 /*
 2     PROBLEM:hdu1007
 3     AUTHER:Nicole Lam
 4     MEMO:模拟
 5 */
 6
 7
 8 #include<cstdio>
 9 using namespace std;
10
11 int main()
12 {
13     int n;
14     scanf("%d",&n);
15     while (n!=0)
16     {
17         int now=0,time=0,next;
18         for (int i=1;i<=n;i++)
19         {
20             scanf("%d",&next);
21             if (next>=now) time+=(next-now)*6+5;
22             else time+=(now-next)*4+5;
23             now=next;
24         }
25         printf("%d\n",time);
26         scanf("%d",&n);
27     }
28
29     return 0;
30 }
时间: 2024-08-05 11:16:06

模拟/hdu 1008 Elevator的相关文章

hdu 1008 elevator

#include<iostream> #include<stdio.h> #include<math.h> #include<algorithm> using namespace std; int main() { int n; while(~scanf("%d",&n)&&n!=0) { int a,b; a=0; int ans=0; for(int i=0;i<n;i++) { scanf("

模拟 --- hdu 12878 : Fun With Fractions

Fun With Fractions Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:65536KB Total submit users: 152, Accepted users: 32 Problem 12878 : No special judgement Problem description A rational number can be represented as the ratio of two integ

hdu 1008为何不对?求大神指导!

/*#include<iostream> using namespace std; int main(){ int n; while (cin >> n){ if (n == 0) break; else if (n > 0 && n < 100){ int sum=0, max,min; int *f = new int[n]; for (int i = 0; i < n; i++) cin >> f[i]; max = min =

1008. Elevator (20)——PAT (Advanced Level) Practise

题目信息: 1008. Elevator (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue 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 w

Programming Ability Test学习 1008. Elevator (20)

1008. Elevator (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue 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 st

杭电 1008 Elevator

杭电ACM 2014暑期集训队--选拔安排~ Elevator Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 40905    Accepted Submission(s): 22387 Problem Description The highest building in our city has only one elevator

甲级1008 Elevator

1008 Elevator (20 分) 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

[PTA] PAT(A) 1008 Elevator (20 分)

目录 Problem Description Input Output Sample Sample Input Sample Output Solution Analysis Code Problem portal: 1008 Elevator (20 分) Description  The highest building in our city has only one elevator. A request list is made up with $N$ positive numbers

【PAT甲级】1008 Elevator (20分)

1008 Elevator 题目: 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