题目描述
Tehran municipality has set up a new charging method for the Congestion Charging Zone (CCZ) which controls the passage of vehicles in Tehran’s high-congestion areas in the congestion period (CP) from 6:30 to 19:00. There are plate detection cameras inside or at the entrances of the CCZ recording vehicles seen at the CCZ. The table below summarizes the new charging method.

Note that the first time and the last time that a vehicle is seen in the CP may be the same. Write a program to compute the amount of charge of a given vehicle in a specific day.

输入
The first line of the input contains a positive integer n (1 ⩽ n ⩽ 100) where n is the number of records for a vehicle. Each of the next n lines contains a time at which the vehicle is seen. Each time is of form :, where is an integer number between 0 and 23 (inclusive) and is formatted as an exactly two-digit number between 00 and 59 (inclusive).

输出
Print the charge to be paid by the owner of the vehicle in the output.

样例输入
4
7:30
2:20
7:30
17:30
样例输出
36000

主要麻烦在读题上,读懂题目就是一道水题,意思是说给了你一天内一辆车出现的情况,选取在6:30到19:00的部分,在这个部分里面选最早和最晚的时间,根据这个时间对照表求出要交的费用,如果一天内这辆车没出现过,那就不需要交钱直接输出0.

AC代码

#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
struct Time{int h;int m;int num;
};
struct Time t[105];
bool cmp(struct Time x,struct Time y)
{if(x.h==y.h) return x.m<y.m;else return x.h<y.h;
}
int main()
{int n;cin>>n;for(int i=0;i<n;i++){scanf("%d:%d",&t[i].h,&t[i].m);t[i].num=t[i].h*100+t[i].m;if(t[i].num<630||t[i].num>1900) i--,n--;}sort(t,t+n,cmp);if(n==0)cout<<"0"<<endl;else if(t[0].num>=630&&t[0].num<=1000){if(t[n-1].num>=630&&t[n-1].num<=1600)cout<<"24000"<<endl;else if(t[n-1].num>=1601&&t[n-1].num<=1900)cout<<"36000"<<endl;}else if(t[0].num>=1001&&t[0].num<=1600&&t[n-1].num>=1001&&t[n-1].num<=1600)cout<<"16800"<<endl;else if(t[0].num>=1001&&t[0].num<=1900&&t[n-1].num>=1601&&t[n-1].num<=1900)cout<<"24000"<<endl;
}

Congestion Charging Zone 水题相关推荐

  1. 【思维】Congestion Charging Zone

    题目描述 Tehran municipality has set up a new charging method for the Congestion Charging Zone (CCZ) whi ...

  2. 水题/poj 1852 Ants

    1 /* 2 PROBLEM:poj1852 3 AUTHER:Nicole 4 MEMO:水题 5 */ 6 #include<cstdio> 7 using namespace std ...

  3. HDU2673-shǎ崽(水题)

    如果不能够直接秒杀的题,就不算水题.又应证了那句话,有时候,如果在水题上卡住,那么此题对于你来说,也就不算是水题了额~~ 刚睡醒,迷迷糊糊. 题目的意思很简单,求一个最大的,再求一个最小的.几乎是什么 ...

  4. 图论刷水题记录(二)(最短路-----SPFA算法)

    继第一篇的后续,又来刷水题了,写的是SPFA算法,这个算法的复杂度比较玄学,感觉能不用就不用了,但是他的好处就是可以判断负圈. 3月26日: 1.POJ 1847 Tram 题意:在一个交通网络上有N ...

  5. 图论刷水题记录(一)(最短路-----dijkstra算法)

    最近实在不知道干些什么,感觉自己除了水题什么都不会做,算了去刷一刷图论的水题吧本来想合起来一起发,想了想太长的话以后看起来也不方便,题目所以今天晚上就先发了dij部分,由上到下由易变难. 1.POJ ...

  6. hdu 2041:超级楼梯(水题,递归)

    超级楼梯Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submissio ...

  7. HDU2568 前进【水题】

    前进 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submiss ...

  8. CF Round #426 (Div. 2) The Useless Toy 思维 水题

    题目链接: http://codeforces.com/contest/834/problem/A 题目描述: 输入起始状态和结束状态和数列长度, 判断旋转方向是顺时针逆时针还是不合理 解题思路: 长 ...

  9. NUC1312 Sum【水题+数学题】

    Sum 时间限制: 1000ms 内存限制: 65536KB 通过次数: 1总提交次数: 1 问题描述 认为自然数是从1-N.将每个数和+或-联系起来,然后计算这个表达式的值我们得到一个和S.这个问题 ...

最新文章

  1. AndroidStudio基础视频教程-整理
  2. 如何使CPU占用率为50%
  3. 工作上,我到底想要什么呢?
  4. TianyaDL_4thread天涯帖子下载4线程版
  5. 如何检测python是否安装_使用Python检查系统中是否安装了一个软件包?
  6. 【图像隐写】基于matlab GUI DCT数字水印嵌入与提取【含Matlab源码 943期】
  7. AutoCAD(英文版)中所有英语词汇的翻译
  8. 74HC595串口转并口芯片学习
  9. 日语输入法的输入规则
  10. Postman汉化教程
  11. node 多版本管理 nvm-window(适用win7 win10)
  12. c语言精髓之编译过程,C语言精髓知识点
  13. angular中copy和extend用法实例
  14. java map替换_在java的Map集合中,怎样更改value的值
  15. 电脑系统数据丢失了是什么原因?找回方法有哪些?
  16. Eclipse安装SVN插件的几种方法
  17. STM32精英,战舰版 蜂鸣器播放菊次郎的夏天
  18. Java之QQ界面实现
  19. 禾赛科技“梦碎”科创板,还在专利官司中败退
  20. 《道德经》| 夫唯不盈,故能蔽而新成

热门文章

  1. mysqldump快速导数据
  2. 解决ArcGIS安装之后出现的Windows installer configures问题
  3. 【WiFi密码破解详细图文教程】ZOL仅此一份 详细介绍从CDlinux U盘启动到设置扫描破解-破解软件论坛-ZOL中关村在线...
  4. 获取设备和 App 信息
  5. Win32 的dll导入问题总结-------------
  6. android优化中国风应用、完整NBA客户端、动态积分效果、文件传输、小说阅读器等源码...
  7. 一个 Java 的 Socket 服务器和客户端通信的例子
  8. ClassNotFoundException: javax.validation.ValidatorFactory
  9. svn: 无法连接主机“127.0.0.1”: 拒绝连接
  10. 设计模式学习--工厂模式