U E D R , A S I H C RSS

usa_selfish/김태진

풀이

//
//  main.cpp
//  usa_selfish
//
//  Created by 김 태진 on 12. 8. 14..
//  Copyright (c) 2012년 __MyCompanyName__. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;


typedef struct cow cow;
struct cow{
	int left;
	int right;
};

int compare(const void* a,const void* b);
int comp(cow a,cow b);

int main()
{
	int N,i,j,k;
	cow arr[50000],temp;
	cow array[10000];
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d %d",&arr[i].left,&arr[i].right);
		//	scanf("%d",&arr[i]);
	}
	qsort((void*)arr, N, sizeof(cow), compare);

	array[0]=arr[0];
	k=1;
	for(i=0;i<N;i++){
		if(array[k-1].right<=arr[i].left){
			array[k]=arr[i];
			k++;
		}
	}
	
	printf("%d",k);
	
    return 0;
}


int compare(const void* a,const void* b)
{
	return ((cow *)a)->right - ((cow *)b)->right;
}
int comp(cow a,cow b)
{
	//if(a.left == b.left)return a.right<b.right;
    return a.right<b.right;

}


ACM_ICPC/2012스터디
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:31:45
Processing time 0.0126 sec