# 贪心-BZOJ-1628-[Usaco2007 Demo]City skyline

Input

Output

Sample Input
10 26

1 1

2 2

5 1

6 3

8 1

11 0

15 2

17 3

20 2

22 1

INPUT DETAILS:

The case mentioned above

Sample Output
6

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
long long int n,w;
typedef struct node
{
long long int x,y;
}node;
vector<node>Node;
void solve(long long int num)
{
long long int startx=num,endx=num;
vector<node>::iterator it=Node.begin();
for(int i=num-1;i>=0;i--)
{
if(Node[i].y==Node[num].y)
startx=i;
else
break;
}
for(int i=num+1;i<Node.size();i++)
{
if(Node[i].y==Node[num].y)
endx=i;
else
break;
}
it+=startx;
for(int i=startx;i<=endx;i++)
Node.erase(it);
}
int main()
{
long long int out=0,x,y;
cin >> n >> w;
for(int i=0;i<n;i++)
{
scanf("%lld %lld",&x,&y);
Node.push_back(node{x,y});
}
while(Node.size()>0)
{
long long int maxs=0,plz=0;
for(int i=0;i<Node.size();i++)
{
if(maxs<Node[i].y)
{
maxs=Node[i].y;
plz=i;
}
}
if(maxs==0)
break;
solve(plz);
out++;
}
cout << out << endl;
return 0;
}


03-04 299
10-05 382
12-24 1642
12-18 94
12-24 586
11-08 919
09-07 70
08-23 2788
11-25 6457
03-02 35
09-25 1369