mirror of
https://github.com/Estom/notes.git
synced 2026-04-05 11:57:37 +08:00
笔试题
This commit is contained in:
38
code_segment/xiaoyu5.cpp
Normal file
38
code_segment/xiaoyu5.cpp
Normal file
@@ -0,0 +1,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;
|
||||
}
|
||||
Reference in New Issue
Block a user