#include<stdio.h>
#include<map>
int main()
{
int cases, i, j, act, answer, min_ind, min_val, temp1, temp2;
scanf("%d",&cases);
for(i=0; i<cases; i++)
{
answer = 0;
scanf("%d", &act);
map<int, int> mymap;
for(j=0; j<act; j++)
{
scanf("%d",&temp1);
scanf("%d",&temp2);
mymap[temp2] = temp1;
}
map<int,int>::iterator it = mymap.begin();
temp1 = it->second;
while(mymap.size() != 0)
{
it = mymap.begin();
if(it->second < temp1)
{
mymap.erase(it);
continue;
}
answer++;
temp1 = it->first;
mymap.erase(mymap.begin());
if(mymap.size() != 0)
{
it = mymap.begin();
while(it->second < temp1)
{
mymap.erase(it);
it = mymap.begin();
}
}
}
printf("%d\n",answer);
}
return 0;
}
I have included the map header as per the STL of C++ but still its not compiling and giving compilation error. I have tried including map.h header file but still getting the same error
Error:
prog.cpp: In function 'int main()':
prog.cpp:13: error: 'map' was not declared in this scope
prog.cpp:13: error: expected primary-expression before 'int'
prog.cpp:13: error: expected `;' before 'int'
prog.cpp:19: error: 'mymap' was not declared in this scope
prog.cpp:22: error: expected primary-expression before 'int'
prog.cpp:22: error: expected `;' before 'int'
Have a look at my code and help me out with this. Thanks for any help in advance.