题解 | #开门人和关门人#
开门人和关门人
https://www.nowcoder.com/practice/a4b37b53a44d454ab0834e1517983215
题目只能简单考虑,测试用例中有得签离时间小于签到时间,按理说上应该是跨了一天的,但本题不能考虑这种情况
#include <iostream>
#include "map"
using namespace std;
int main() {
int n;
while (cin >> n) { // 注意 while 处理多个 case
// cout << a + b << endl;
map<string, string> inMap;
map<string, string> outMap;
while (n--) {
string name;
string inTime;
string outTime;
cin >> name >> inTime >> outTime;
inMap[inTime] = name;
outMap[outTime] = name;
}
cout << inMap.begin()->second << ' ';
auto it = outMap.end();
it--;
cout << it->second << endl;
}
}
// 64 位输出请用 printf("%lld")

查看14道真题和解析