hiho week 152 register

Ended

Participants:252

Verdict:Accepted
Score:100 / 100
Submitted:2017-06-03 14:06:18

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<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct node{
    int x,y;
}A[5][100100];
bool cmp(node x,node y){
    return x.x<y.x;
}
int n,m,n1,m1;
int ss()
{
    sort(A[1]+1,A[1]+1+n,cmp);
    sort(A[2]+1,A[2]+1+m,cmp);
    n1=m1=0;
    int ans=0;
    int i=1,x,y;
    while (i<=n)
    {
        x=A[1][i].x;
        y=A[1][i].y;
        i++;
        while (i<=n&&A[1][i].x<=y){
            y=max(y,A[1][i].y);
            i++;
        }
        n1++;
        A[3][n1].x=x;
        A[3][n1].y=y;
        ans+=y-x;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX