Solution in c++
#include <bits/stdc++.h>
using namespace std;
string it="YES";
int n,t1,t2;
vector<pair<int,int> > all;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n;
for(int i=0;i<n;i++)
{
cin>>t1>>t2;
all.push_back(make_pair(t1,t2));
if(i>0)
{
if(t1<=all[i-1].second && t2<=all[i-1].second )all[i].second=max(t1,t2);
else if(t2<=all[i-1].second && t1>all[i-1].second)all[i].second=t2;
else if(t1<=all[i-1].second && t2>all[i-1].second)all[i].second=t1;
else it="NO";
}
else all[0].second=max(t1,t2);
}
cout<<it;
return 0;
}
0 التعليقات:
إرسال تعليق