forked from Estom/notes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxiaoyu5.cpp
More file actions
38 lines (37 loc) · 703 Bytes
/
xiaoyu5.cpp
File metadata and controls
38 lines (37 loc) · 703 Bytes
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
32
33
34
35
36
37
38
#include<iostream>
#include<vector>
#include<algorithm>
// #include<sstream>
using namespace std;
struct Node{
int val;
int pos;
Node(int v,int p){
val=v;
pos=p;
}
bool operator<(const Node& b){
return val<b.val;
}
};
int main(){
// string s = "4\n1 2\n2 3\n3 5\n4 3\n";
// istringstream cin(s);
int N;
cin>>N;
vector<Node> vec;
while(N--){
int x,y;
cin>>x>>y;
vec.push_back(Node(x,1));
vec.push_back(Node(x+y+1,-1));
}
sort(vec.begin(),vec.end());
int max_num=0;
int num=0;
for(auto v:vec){
num+=v.pos;
max_num=max(num,max_num);
}
cout<<max_num<<endl;
}