PAT-A 1006. Sign In and Sign Out (25)
来源:互联网 发布:苹果6手机壳淘宝 编辑:程序博客网 时间:2024/05/01 07:45
这道题没什么难度 水题
用map或者vector等容器来做速度很快
我这里用map, 把时间转换成数字,把数字用作map的key 然后维护这个key以从小到大 从大到小 两种方式排序
然后分别输出第一个值即可
#include<iostream>#include<map>#include<vector>#include<cstdio>#include<string>using namespace std;int chartoint(string s) {int a = (s[0] - '0') * 10;int b = (s[1] - '0');int shi = a + b;int c = (s[3] - '0') * 10;int d = (s[4] - '0');int fen = c + d;int e = (s[6] - '0') * 10;int f = (s[7] - '0');int miao = e + f;return shi * 3600 + fen * 60 + miao;}map<string, int, less<int> > roin;map<string, int, greater<int> > roout;int n;void solver() {map<string, int> ::iterator it;it = roin.begin();cout << (it->first) << " ";it = roout.begin();cout << (it->first);}int main(){cin >> n;string s, s1,s2;int in, out;for (int i = 0; i < n; i++) {cin >> s >> s1 >> s2;in = chartoint(s1);out = chartoint(s2);roin[s] = in;roout[s] = out;} return 0;}
0 0
- PAT A 1006. Sign In and Sign Out (25)
- PAT A 1006. Sign In and Sign Out (25)
- PAT-A 1006. Sign In and Sign Out (25)
- PAT(A) - 1006. Sign In and Sign Out (25)
- PAT-A 1006. Sign In and Sign Out (25)
- PAT A 1006. Sign In and Sign Out (25)
- PAT-A-1006. Sign In and Sign Out (25)
- PAT-A 1006. Sign In and Sign Out (25)
- PAT-A 1006. Sign In and Sign Out
- PAT 1006. Sign In and Sign Out
- PAT 1006. Sign In and Sign Out
- 【PAT】1006. Sign In and Sign Out
- PAT-Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)-PAT
- 【PAT】1006. Sign In and Sign Out (25)
- 【PAT Advanced Level】1006. Sign In and Sign Out (25)
- PAT 1006. Sign In and Sign Out (25)
- 【PAT (Advanced Level)】1006. Sign In and Sign Out (25)
- 【c++11并不遥远】使xcode工程支持c++11特性
- SQL Server 2008 R2 清空数据库中ldf日志文件
- PythonChallenge过关斩将录-0~10关
- maxHappiness
- 设计模式学习笔记之迪米特法则
- PAT-A 1006. Sign In and Sign Out (25)
- [LeetCode 188] Best Time to Buy and Sell Stock IV
- id instancetype 区别
- LeetCode 题解(249) : Closest Binary Search Tree Value
- exits和In的区别(http://hi.baidu.com/delphi_relive/blog/item/d7c0034a49c4932208f7ef21.html)
- PHP实现验证码
- UPlayer播放器问题相关
- Linux tcpdump命令详解
- 多态 特征