Advertisement
sazid_iiuc

Untitled

May 8th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int testcase;
  7.     cin>>testcase;
  8.  
  9.     for(int j=0; j<testcase; j++)
  10.     {
  11.         int field, flag=0, check_play, check_win;
  12.         cin>>field;
  13.         int play[field], win[field];
  14.         for(int i=0; i<field; i++)
  15.         {
  16.             cin>>play[i]>>win[i];
  17.         }
  18.  
  19.         if(play[0]<win[0])
  20.         {
  21.             flag++;
  22.         }
  23.  
  24.         for(int i=1; i<field; i++)
  25.         {
  26.             if(play[i]<win[i])
  27.             {
  28.                 flag++;
  29.             }
  30.  
  31.             check_play=play[i]-play[i-1];
  32.             check_win=win[i]-win[i-1];
  33.  
  34.             if(check_play<0 || check_win<0)
  35.             {
  36.                 flag++;
  37.             }
  38.  
  39.             if(check_play<check_win)
  40.             {
  41.                 flag++;
  42.             }
  43.         }
  44.         if(flag>0)
  45.         {
  46.             cout<<"NO"<<endl;
  47.         }
  48.         else
  49.             cout<<"Yes"<<endl;
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement