hiho week 152 register

Ended

Participants:252

Verdict:Accepted
Score:100 / 100
Submitted:2017-05-29 21:00:56

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring> 
#include<algorithm>
using namespace std;
struct node
{
    int x,y;
    bool operator <(const node&b) const{return x<b.x||x==b.x&&y<b.y;}
}a[100005],b[100005],c[100005];
int main()
{
    int n,m,i,j,ans=0;
    int h1=1,h2=1;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)
    scanf("%d%d",&a[i].x,&a[i].y);
    sort(a+1,a+1+n);
    b[h1].x=a[1].x;
    b[h1].y=a[1].y;
    for(i=2;i<=n;i++)
    {
        if(a[i].x>b[h1].y)
        {
            h1++;
            b[h1].x=a[i].x;
            b[h1].y=a[i].y;
        }
        else b[h1].y=max(b[h1].y,a[i].y);
    }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX