hiho week 155 register

Ended

Participants:382

Verdict:Accepted
Score:100 / 100
Submitted:2017-06-20 23:35:30

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
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[]) {
    int n,s,e; 
    scanf("%d", &n);
    typedef pair<int, int> T;
    vector<T> p;
    for (int i = 0; i < n; ++i) {
        scanf("%d%d",&s,&e);
        p.push_back({s,1});
        p.push_back({e,-1});
    }
    sort(p.begin(), p.end());
    int maxVal = 0;
    int val = 0;
    for (int i = 0; i < 2*n; ++i) {
        val += p[i].second;
        maxVal = max(val, maxVal);
    }
    printf("%d", maxVal);
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX