ACM The Biggest Date














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;

}





Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment