Untitled

 avatar
user_5668965
c_cpp
a year ago
1.2 kB
8
Indexable
#include<bits/stdc++.h>

using namespace std;

#define ll long long int

int main()
{
      ll t;
      cin >> t;
      while(t--)
      {
            ll n;
            cin >> n;
            
            queue<pair< ll, ll>> qp;
            
            for(ll i = 0; i < n; i++)
            {
                  ll x, y;
                  cin >> x >> y;
                  
                  qp.push({x,y});
            }
            
            ll t = 0;
            
            while(!qp.empty())
            {
                  if(t < qp.front().first - 1)
                  {
                        t = qp.front().first - 1;
                  }
                  
                  if(qp.front().second >= t + 1)
                  {
                        
                        cout << t + 1 << " ";
                        t++;
                        qp.pop();
                  }
                  else
                  {
                        cout << 0 << " ";
                        qp.pop();
                  }
            }
            cout << endl;
      }
      
      return 0;
}
Editor is loading...
Leave a Comment