Code running fine in my ide but showing wrong compile here why?

#include
#include
using namespace std;
int main()
{
int n;
cin >> n;
while (n)
{
int num;
cin >> num;
pair<int, int> s[num];
int work = 1;
for (int i = 0; i < num; i++)
{
cin >> s[i].first;
cin >> s[i].second;
}
for (int i = 1; i < num; i++)
{
if (s[i].first >= s[i - 1].second)
{
work++;
}
else
{
s[i].first = s[i - 1].first;
s[i].second = s[i - 2].second;
}
}
cout << work<<endl;
n–;
}
return 0;
}

hi… ur logic is not correct… u have to sort them in order such that activities that finish early should come before…
https://ide.codingblocks.com/s/589805 refer this

yeh got it thanks a lot

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.