So I’m unsure as to why this code is getting a WA. I’ve only run one test case(the one that was provided) locally and it produces the expected output. Any help would be greatly appreciated. Thanks!
Note: It was an == instead of a >= that was causing the problem.
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
int u;
int a;
int b;
int s;
int x;
int pos;
int time;
vector< pair <int,int> > times;
cin >> t;
while(t--)
{
times.clear();
time=0;
x=0;
pos=0;
cin >> u;
s = u;
while(u--)
{
cin >> a;
cin >> b;
times.push_back(make_pair(b, a));
}
sort(times.begin(), times.end());
time=times[pos].first;
x++;
while(pos<s)
{
pos++;
if(times[pos].second==time)
{
x++;
time=times[pos].first;
}
}
cout << x << endl;
}
return 0;
}