简单的谁先开门关门
/*
map简单的使用
恩 还有就是map.count(k) 就是指k这个元素有没有在这个map里面
第一个是键 第二个是值
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<map>
using namespace std;
map<string,string>mp1,mp2;
string name,begintime,endtime;
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
cin>>name>>begintime>>endtime;
mp1[begintime]=name;
mp2[endtime]=name;
}
map<string,string>::iterator it1=mp1.begin();
map<string,string>::iterator it2=mp2.end();
it2--;
cout<<it1->second<<endl;
cout<<it2->second<<endl;
return 0;
}
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
struct node
{
char name[20];
char begin[10];
char end[10];
}what[200];
bool cmp1(node a,node b)
{
return strcmp(a.begin,b.begin)==-1;
}
bool cmp2(node a,node b)
{
return strcmp(a.begin,b.begin)==1;
}
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%s %s %s",what[i].name,what[i].begin,what[i].end);
sort(what+1,what+1+n,cmp1);
printf("%s\n",what[1].name);
sort(what+1,what+1+n,cmp2);
printf("%s\n",what[1].name);
}