I have problem with this task for a long time, I think that idea is good, but I got 4/10 wa:-S
So, here is my code if anyone know what's wrong with it just post it....
==================================
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main()
{
int n;
int sum( 0 );
scanf( "%d", &n );
pair< int, int > kutije[n];
vector< bool > pro( n, true );
map< int, bool > MAP;
for( int i = 0; i < n; i++ )
scanf( "%d %d", &kutije[i].first, &kutije[i].second );
sort( kutije, kutije+n );
for( int i = 0; i < n-1; i++ )
for( int j = i+1; j < n; j++ )
if( kutije[i].second <= kutije[j].second && ! MAP[j] )
{
MAP[j] = true;
sum ++;
break;
}
cout << n - sum << endl;
return 0;
}
==================================
TNX in advance..!
So, here is my code if anyone know what's wrong with it just post it....
==================================
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main()
{
int n;
int sum( 0 );
scanf( "%d", &n );
pair< int, int > kutije[n];
vector< bool > pro( n, true );
map< int, bool > MAP;
for( int i = 0; i < n; i++ )
scanf( "%d %d", &kutije[i].first, &kutije[i].second );
sort( kutije, kutije+n );
for( int i = 0; i < n-1; i++ )
for( int j = i+1; j < n; j++ )
if( kutije[i].second <= kutije[j].second && ! MAP[j] )
{
MAP[j] = true;
sum ++;
break;
}
cout << n - sum << endl;
return 0;
}
==================================
TNX in advance..!