PAT 1008. Elevator (20)(C++)

题目描述在这里插入图片描述

简单模拟题(水题

#include<cstdio>
using namespace std;
int main(){
    
    
	int n;
	scanf("%d",&n);
	int floor=0;
	int future;
	int time=n*5;
	while(n--){
    
    
		scanf("%d",&future);
		if(future>floor){
    
    
			time+=(future-floor)*6;
		}
		else{
    
    
			time+=(floor-future)*4;
		}
		floor=future;
	}
	printf("%d",time);
}

猜你喜欢

转载自blog.csdn.net/qaqaqa666/article/details/112544571
今日推荐