题目描述

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 <hour>:<minute>, where <hour> is an integer number between 0 and 23 (inclusive) and <minute> 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

题目大意:

emmmm,此题题目有毒,感觉它说的很模糊,按照代码的思路,最终的意思就是:先输入一个整数n,下面n行输入n个时间(ps:同一天内的),问根据表格最终产生的费用是多少?

解题思路:

需要先对时间进行一个排序,然后从前往后找到第一个符合列1的时间,再从后往前找到第一个符合列2的时间,根据这两个时间即可得到最终的费用。

代码:

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <set>
#include <utility>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define inf 0x3f3f3f3f
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define lep(i,l,r) for(int i=l;i>=r;i--)
#define ms(arr) memset(arr,0,sizeof(arr))
//priority_queue<int,vector<int> ,greater<int> >q;
const int maxn = (int)1e5 + 5;
const ll mod = 1e9+7;
int ju1(int h,int m)
{if(h==6&&m>=30) return 1;else if(h>=7&&h<=9) return 1;else if(h==10&&m==0) return 1;else if(h==10&&m>0) return 2;else if(h>=11&&h<=15) return 2;else if(h==16&&m==0) return 2;else if(h==16&&m>0) return 3;else if(h>=17&&h<=18) return 3;else if(h==19&&m==0) return 3;else return -1;
}
int ju2(int h,int m) {if(h==6&&m>=30) return 1;else if(h>=7&&h<=9) return 1;else if(h==10&&m==0) return 1;else if(h==10&&m>0) return 2;else if(h>=11&&h<=15) return 2;else if(h==16&&m==0) return 2;else if(h==16&&m>0) return 3;else if(h>=17&&h<=18) return 3;else if(h==19&&m==0) return 3;else return -1;
}
struct node
{int h,m;
}arr[120];
bool cmp(node a,node b) {if(a.h==b.h) return a.m<b.m;else return a.h<b.h;
}
int main()
{#ifndef ONLINE_JUDGEfreopen("in.txt", "r", stdin);#endif//freopen("out.txt", "w", stdout);ios::sync_with_stdio(0),cin.tie(0);int n;scanf("%d",&n);rep(i,1,n) scanf("%d:%d\n",&arr[i].h,&arr[i].m);sort(arr+1,arr+1+n,cmp);int t1,t2;for(int i=1;i<=n;i++) {t1=ju1(arr[i].h,arr[i].m);if(t1!=-1) break;}for(int i=n;i>=1;i--) {t2=ju2(arr[i].h,arr[i].m);if(t2!=-1) break;}int ans=0; if(t1==1&&(t2==1||t2==2)) ans=24000;else if(t1==1&&t2==3) ans=36000;else if(t1==2&&t2==2) ans=16800;else if((t1==2||t1==3)&&t2==3) ans=24000;printf("%d\n",ans);return 0;
}

【思维】Congestion Charging Zone相关推荐

  1. Congestion Charging Zone 水题

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

  2. ios apple语音性别_iOS 14:Apple终于听了

    ios apple语音性别 Every year, Apple release the latest version of iOS, one of the most popular operating ...

  3. wpsppt流程图联系效果_| JEAM | 文章精选:大城市收取交通拥堵费的影响与效果

    点击蓝字关注我们 文章导读 近年来,交通拥堵在中国各个城市尤其是大城市日益严重,停车困难.空气污染和噪声等问题也随之出现.目前已有的措施如限制购车.限制出行均收效甚微.为解决上述问题,北京市交通运输委 ...

  4. TED+成长性思维+Carol Deweck+The Power of Yet

    TED+成长性思维+Carol Deweck+The Power of Yet fixed mindset growth mindset I heard about a high school in ...

  5. 关于ftp的说法错误的是_斯坦福教授:成长型思维的养成,只需要换个说法,思维是可以训练的!...

    作者:Carol Dweck转载自:SevenEducation(ID:USA7EDU) 斯坦福研究表明,拥有成长型思维的孩子做事不易放弃,更能从过程中享受到乐趣,更容易寻求帮助,复原力更强,也就是更 ...

  6. 终身成长----“成长型思维”

    在斯坦福教育理念中,有一个叫"成长型思维(growth mindset)"的概念,它是相对固定型思维的一种心智模式, 被公认为近几十年里最有影响的心理学研究之一. 研究表明,拥有成 ...

  7. Widget-苹果.谷歌和诺基亚着迷的网络新思维

    Widget-苹果.谷歌和诺基亚着迷的网络新思维 2007.09.10  来自:环球企业家      共有评论(4)条 发表评论   [收藏到我的网摘] 这家网络巨头的方向调整,折射出一个有趣的现实: ...

  8. 别再自称“码农”了,编程是门思维的艺术

    一个足球评论员可能并不会踢足球,却并不妨碍在解说比赛时对某某球星的技艺评头论足.同样我也绝不敢以高明的程序员自居,而只是以类似足球评论员的角度来阐述我对程序员的理解.这样,大家也许就不以我为鄙薄狂妄了 ...

  9. 【学习总结】Apsara Clouder云计算技能认证:云服务器基础运维与管理+思维导图

    [学习总结]Apsara Clouder云计算技能认证:云服务器基础运维与管理 课程目标 3个理由拥抱云服务器 什么是云服务器? 使用云服务器的好处? 理由一:简单易用 理由二:高效稳定 理由三:成本 ...

最新文章

  1. 皮一皮:这算画蛇添足?
  2. 数据结构——折半查找
  3. 对象之function
  4. Spring 为啥默认把 bean 设计成单例的?
  5. 二维码原理--开胃小知识
  6. CSS3动画大全(附源码)flex布局,grid布局3d旋转,图像模糊,文字发光
  7. linux下分割文件的方法,关于linux系统下分割大文件的方法
  8. 光纤光信号闪红灯_电信光纤光猫光信号闪红灯怎么处理
  9. asp.net web submit链接页面_De1CTF2020的Web部分题解
  10. java编译异常有哪些_编译时JAVA最常见的错误有哪些
  11. vue单文件结构理解
  12. 捕鱼达人 FishMaster 记录(Done)
  13. 【MPPT光伏】基于MPPT的光伏并网系统的simulink仿真
  14. java 调用bat脚本 等待返回_java程序调用bat脚本
  15. 软件开发过程与项目管理(8.软件项目质量计划)
  16. Uclinux、Linux区别
  17. 目标检测正负样本区分和平衡策略总结
  18. 基于ESP32与phyphox的DIS实验制作(4)-使用超声波位移传感器研究弹簧振子的运动
  19. win10怎么修改DNS
  20. 如何靠3D建模月入2W+?

热门文章

  1. java垃圾回收 分代_Java分代垃圾回收策略原理详解
  2. qt中拖动窗口widget
  3. React之函数式组件使用props
  4. java long bigdecimal,通过Java中的long创建BigDecimal值
  5. Linux文件的三种时间属性
  6. xrdpdf卡片在哪可下载_暑假学习英语字母,就是这样简单(附可打印字母卡下载)...
  7. 2 数据源配置_如何在程序运行中动态切换数据源?架构师必读秘笈
  8. mysqldb mysql config,安装mysqldb python界面时找不到mysql_config
  9. php中手机端ajax上拉加载更多,jQuery手机网页上拉加载更多
  10. java 输入16进制_尝试使用十六进制输入来使用小端和大端