杭州電OJ Elevator
3351 ワード
エレヴァルト
ソース:http://acm.hdu.edu.cn/showproblem.php?pid=1008
Time Limit:2000/1000 MS(Java/Others) メモリLimit:65536/32768 K(Java/Others)Total Submission(s):35606 Acceepted Submission(s):19443
Problem Description
The highest building in our city has only one elevator.A request list is made up with N positive numbers.The numbers denote aaah fhich the elevator will stop、in speciifed ordededer.It cospspspspspspspeciiiiiiiifd codededededededededededededes.It.It.It.Itstststss.It cospspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspat each stop.
For a given request list、you are to compute the total time spent to fulfill the requests on the list.The elevatos is on the 0 th flover the begining and does not have to return to the ground frowhererereles.
Input
The re are multile test cases.Each case contains a positive integer N,followed by N positive numbers.All the numbers in the input are less than 100.A test case with N=0 denotes the end of input.Theis procest cast
Output
Print the total time on a single line for each test case.
Sample Input
Sample Output
Author
ZHENG,Jianqiang
ソurce
ZJCPC 2004
Recommund
JGS hining | We have carefully selected several simiar probles for you: 1005 1004 1009 1021 1003
私たちの都市で一番高い建物はエレベーターしかありません。エレベーターの命令はN個の数字からなっています。これらの数字はこの階でエレベーターが止まることを表しています。これらの数字は順番が決まっています。上の階に行くと6秒、下の階に行くと4秒、エレベーターが止まっていない時間は5秒です。与えられた入力の合計時間を計算します。エレベーターは0階から始まります。
問題:停止する階を配列b[100]で保存し、n[1000]保存時間。まずエレベーターが止まる時間を計算してから、階段を上がる時にかかる時間を計算します。
最後の総出力時間は。
ソース:http://acm.hdu.edu.cn/showproblem.php?pid=1008
Time Limit:2000/1000 MS(Java/Others) メモリLimit:65536/32768 K(Java/Others)Total Submission(s):35606 Acceepted Submission(s):19443
Problem Description
The highest building in our city has only one elevator.A request list is made up with N positive numbers.The numbers denote aaah fhich the elevator will stop、in speciifed ordededer.It cospspspspspspspeciiiiiiiifd codededededededededededededes.It.It.It.Itstststss.It cospspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspspat each stop.
For a given request list、you are to compute the total time spent to fulfill the requests on the list.The elevatos is on the 0 th flover the begining and does not have to return to the ground frowhererereles.
Input
The re are multile test cases.Each case contains a positive integer N,followed by N positive numbers.All the numbers in the input are less than 100.A test case with N=0 denotes the end of input.Theis procest cast
Output
Print the total time on a single line for each test case.
Sample Input
1 2
3 2 3 1
0
Sample Output
17
41
Author
ZHENG,Jianqiang
ソurce
ZJCPC 2004
Recommund
JGS hining | We have carefully selected several simiar probles for you: 1005 1004 1009 1021 1003
私たちの都市で一番高い建物はエレベーターしかありません。エレベーターの命令はN個の数字からなっています。これらの数字はこの階でエレベーターが止まることを表しています。これらの数字は順番が決まっています。上の階に行くと6秒、下の階に行くと4秒、エレベーターが止まっていない時間は5秒です。与えられた入力の合計時間を計算します。エレベーターは0階から始まります。
問題:停止する階を配列b[100]で保存し、n[1000]保存時間。まずエレベーターが止まる時間を計算してから、階段を上がる時にかかる時間を計算します。
最後の総出力時間は。
#include<iostream>
using namespace std;
int n[1000]={};
int b[100];
int main()
{
int N,i,j=0;
cin>>N;
while(N!=0){
for(i=0;i<N;i++){
cin>>b[i];
}
n[j]+=N*5+b[0]*6;
for(i=0;i<N-1;i++)
{
if(b[i]<b[i+1])
n[j]+=(b[i+1]-b[i])*6;
else
n[j]+=(b[i]-b[i+1])*4;
}
j++; cin>>N;
}
for(i=0;n[i]!=0;i++)
cout<<n[i]<<endl;
return 0;
}