Skip to content

Instantly share code, notes, and snippets.

@I-See-You
Created January 31, 2016 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save I-See-You/e8066e0b3a2ffbf5430e to your computer and use it in GitHub Desktop.
Save I-See-You/e8066e0b3a2ffbf5430e to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
struct data
{
string s;
int day,month,year;
}input[101];
bool comp(data x,data y)
{
if(x.year != y.year) return x.year < y.year;
if(x.month != y.month) return x.month < y.month;
return x.day < y.day;
}
int main()
{
int n;
while(cin >> n)
{
for(int i=0;i<n;i++){
string ss;
int x,y,z;
cin >> ss >> x >> y >> z;
input[i].s = ss;
input[i].day = x;
input[i].month = y;
input[i].year = z;
}
sort(input,input+n,comp);
// for(int i=0;i<n;i++) cout << input[i].s << endl;
cout << input[n-1].s << endl << input[0].s << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment