URAL 1203 Scientific Conference dp?贪心
题目:click here
分明就是贪心怎么会在dp的专题
1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef unsigned long long ll; 4 const int INF = 0x3f3f3f3f; 5 const int M = 1e5+3; 6 7 struct Node 8 { 9 int F, S; 10 bool operator < ( const Node x ) const { 11 return S < x.S; 12 } 13 } p[M]; 14 15 int n; 16 int main() { 17 while( ~scanf("%d", &n ) ) { 18 for( int i=0; i<n; i++ ) 19 scanf("%d%d", &p[i].F, &p[i].S ); 20 sort( p, p+n ); 21 int pre = 0; 22 int ans = 0; 23 for( int i=0; i<n; i++ ) { 24 if( p[i].F > pre ){ 25 ans++; 26 pre = p[i].S; 27 } 28 } 29 printf("%d\n", ans ); 30 } 31 return 0; 32 }