Problem Link: http://acm.epoka.edu.al:8888/en/problem-pid-c4aa?ps=1&smt=a&smpwid=0
#include <bits/stdc++.h>
using namespace std;
bool sortyear( const vector<int>& v1,const vector<int>& v2 )
{
if(v1[2]==v2[2] && v1[1]==v2[1])
{
return (v1[0]>v2[0]); //third condition
}
if(v1[1]==v2[1] && v1[0]==v2[0])
{
return (v1[1]>v2[1]); // second condition
}
if(v1[2]==v2[2])
{
return (v1[1]>v2[1]);
}
//return (x.first.size()<y.first.size()); //first condition
return v1[2] > v2[2];
}
int main()
{
int i,j,k,l,m,n,t,d,y;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
cin>>t;
vector< vector<int> > vect;
for(i=1;i<=t;i++)
{
vector<int>v;
cin>>d>>m>>y;
v.push_back(d);
v.push_back(m);
v.push_back(y);
vect.push_back(v);
}
sort(vect.begin(), vect.end(),sortyear);
cout<<vect[0][0]<<" "<<vect[0][1]<<" "<<vect[0][2]<<endl;
return 0;
}
0 comments:
Post a Comment