1006. Sign In and Sign Out (25)
来源:互联网 发布:android 模仿淘宝首页 编辑:程序博客网 时间:2024/06/05 08:58
1.采用algorithm.h里面的sort函数,对时间进行排序,需要重写比较函数
//#include<string>//#include <iomanip>#include<vector>#include <algorithm>//#include<stack>#include<set>#include<queue>#include<map>//#include<unordered_set>//#include<unordered_map>//#include <sstream>//#include "func.h"//#include <list>#include<stdio.h>#include<iostream>#include<string>#include<memory.h>using namespace std;int time2Int(string s){int hour = (s[0] - '0') * 10 + s[1] - '0';int min = (s[3] - '0') * 10 + s[4] - '0';int sec = (s[6] - '0') * 10 + s[7] - '0';return hour * 3600 + min * 60 + sec;}struct people{int begin, end;string ID;people() :begin(0), end(0), ID(""){};};bool cmpBegin(const people&a, const people&b){if (a.begin < b.begin) return true;else return false;}bool cmpEnd(const people&a, const people&b){if (a.end > b.end) return true;else return false;}int main(void) {int n;cin >> n;vector<people> p(n);for (int i = 0; i < n; i++){string a, b, c;cin >> a >> b >> c;p[i].ID = a;p[i].begin = time2Int(b);p[i].end = time2Int(c);}string first = "";sort(p.begin(), p.end(), cmpBegin);first = p[0].ID;sort(p.begin(), p.end(), cmpEnd);string last = p[0].ID;cout << first << " " << last << endl;return 0;}
0 0
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)
- 1005. Spell It Right (20)
- [OpenJudge-NOI]乘积最大的拆分
- [LeetCode] Longest Substring Without Repeating Characters
- 鼎智收购北斗星手机网 推全新手机品牌青葱
- [OpenJudge-NOI]连乘积末尾0的个数
- 1006. Sign In and Sign Out (25)
- eclipse不能写入classpath
- [OpenJudge-NOI]质数的和与积
- POJ——3253 Fence Repair(优先队列)
- 1007. Maximum Subsequence Sum (25)
- javaWeb--API 自动化测试框架分享
- 周鸿祎携奇酷手机999元“射杀”行业暴利
- 16G内存的iPhone手机能扩容?是真的 暴力拆机失质保! 值得吗?
- [OpenJudge-NOI]最大公约数与最小公倍数