# PROBLEM LINK:

Practice

Contest

* Author:* Soumy Jain

*Divyank Goyal*

**Tester:***Anugya Jain*

**Editorialist:**# DIFFICULTY:

EASY

# PREREQUISITES:

Ad-hoc

# PROBLEM:

You are given N rectangle boxes with the width and height of the rectangle box and you can rotate the rectangle boxes clockwise any number of times but can’t change the order of the box. Now, you have to print YES if the height of boxes can be made in non-increasing order otherwise NO.

# EXPLANATION:

Non-increasing means that every element is less than or equal to the one before it.

so the sequence will be something will this

h0>=h1>=h2>=…>=hn

It means that we have to choose the max among (height and width) and if the maximum of (hi, wi) is greater than the previously calculated height value then try to take a minimum of (hi and wi) if it satisfies the condition then go ahead otherwise return false.

# SOLUTIONS:

## Editorialist's Solution

```
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin>>n;
ll temp=1e9;
int flag=0;
for(int i=0;i<n;i++)
{
ll x,y;
cin>>x>>y;
int r=max(x,y);
if(r<=temp)
{
temp=r;
}
else
{
r=min(x,y);
if(r<=temp)
temp=r;
else
{
flag=1;
}
}
}
if(flag==0)
cout<<"YES";
else
cout<<"NO";
return 0;
}
```