AcWing 1478. 签到与签出
原题链接
简单
作者:
og_
,
2020-05-26 18:08:51
,
所有人可见
,
阅读 411
C++ 代码
#include<bits/stdc++.h>
using namespace std;
const int N=15;
string s[N];
map<string,pair<int,int> > mp;
int main(){
int n,i=0;
cin>>n;
int m=n;
while(n--){
cin>>s[i];
int h1,m1,s1,h2,m2,s2;
scanf("%d:%d:%d %d:%d:%d",&h1,&m1,&s1,&h2,&m2,&s2);
int date1=(m1*60+s1+h1*3600),date2=(m2*60+s2+h2*3600);
mp[s[i]]={date1,date2};
i++;
}
int min=24*3600,max = 0;
string s_min="",s_max="";
for(int j = 0;j<m;j++){
if(mp[s[j]].first<min) {
min = mp[s[j]].first;
s_min=s[j];
}
if(mp[s[j]].second>max){
max = mp[s[j]].second;
s_max = s[j];
}
}
cout<<s_min<<" "<<s_max;
return 0;
}