1006 Problem F
来源:互联网 发布:网络尖兵官网 编辑:程序博客网 时间:2024/05/22 11:39
电梯从零层开始 每上一层耗时6s 下一层耗时4s 在每层停留 5s;不会再回到零层;
先输入一个数N代表停留的楼层数。然后再输入N个数 代表在哪层楼停留。
先初始化time 等于N*5;然后第一个数*6s 以后每一个数与前一个数比较 如果后面的大 time 加两数之差*6 如果前面的数小 time+前面减后的差*4s;
最后的time 就是耗时。
// ConsoleApplication3.cpp : 定义控制台应用程序的入口点。////#include "stdafx.h"#include <iostream>#include<fstream>#include<vector>#include <algorithm>#include<math.h>#include<string.h>using namespace std;int f[100];int main(){ fstream cin("E:/C++/IN/aaa.txt"); int a; while(cin>>a&&a) { int time=a*5; memset(f,0,100); for(int i=0;i<a;i++) cin>>f[i]; time+=f[0]*6; // cout<<time<<" "; for(int i=1;i<a;i++) { if(f[i]>f[i-1])time+=(f[i]-f[i-1])*6; else time+=(f[i-1]-f[i])*4; } cout<<time<<endl; } return 0;}
1 0
- 1006 Problem F
- 1006 Problem F
- 1006 Problem F
- 1006 Problem F
- 1006 Problem F
- 贪心算法 problem f(1006)
- Problem F
- ProBlem F
- Problem F
- Problem F
- Problem F
- Problem F
- problem F
- Problem f
- Problem F
- Problem F
- Problem F
- Problem F
- android shape的使用
- c#开发中遇到System.AccessViolationException
- iOS进程间通信之CFMessagePort/还有 url schema
- ZOJ 1100 Mondriaan's Dream【状态压缩】【DP】【DFS】
- Windows系统下将MAC系统的可执行dmg文件转换为ISO文件 & 安装到虚拟机的MAC系统上
- 1006 Problem F
- [数学基础]游戏开发数学技术
- JVM(3)——JVM类加载器
- 深度学习资源汇总
- socket编程(三)---- 简单的客户端
- 打印***图形
- Win7下 python安装Scrapy
- 蓝牙、红外线与wifi 区别以及不同频段无线电磁波的穿墙和绕过障碍物能力(转)
- QQ在Android端登录也太操蛋了吧