喜马拉雅
This commit is contained in:
parent
7e3e0ceda4
commit
48ec4912ca
|
@ -0,0 +1,3 @@
|
|||
# 标题
|
||||
|
||||
* 内容
|
|
@ -0,0 +1,3 @@
|
|||
# 标题
|
||||
|
||||
* 内容
|
|
@ -0,0 +1,47 @@
|
|||
#include<iostream>
|
||||
#include <algorithm>
|
||||
using namespace std;
|
||||
int n;
|
||||
bool ce[100001]={0};
|
||||
struct link{
|
||||
int x,y;
|
||||
}a[100001];
|
||||
bool pan(link yi,link er){
|
||||
return yi.x<er.x;
|
||||
}
|
||||
int main(){
|
||||
cin>>n;
|
||||
for(int i=0;i<n;i++){
|
||||
cin>>a[i].x>>a[i].y;
|
||||
}
|
||||
sort(a,a+n,pan);
|
||||
/*
|
||||
for (int i = 0; i <n; i++) {
|
||||
cout<<a[i].x<<" "<<a[i].y <<endl;
|
||||
}*/
|
||||
int now=0,ans=n;
|
||||
for(int i=1;i<n;i++){
|
||||
if(a[now].y+a[now].x-a[i].x>=a[i].y){
|
||||
ce[i]=1;
|
||||
//cout<<ans<<" "<<a[i].x<<" "<<a[i].y <<endl;
|
||||
}else{
|
||||
now=i;
|
||||
}
|
||||
}
|
||||
now=n-1;
|
||||
if(ce[now]==1){
|
||||
ans--;
|
||||
}
|
||||
for(int i=n-2;i>=0;i--){
|
||||
if(a[now].y-(a[now].x-a[i].x)>=a[i].y){
|
||||
ce[i]=1;
|
||||
//cout<<ans<<" "<<a[i].x<<" "<<a[i].y <<endl;
|
||||
}else{
|
||||
now=i;
|
||||
}
|
||||
if(ce[i]==1){
|
||||
ans--;
|
||||
}
|
||||
}
|
||||
cout<<ans;
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,6 @@
|
|||
5
|
||||
25 3
|
||||
105 30
|
||||
20 50
|
||||
10 17
|
||||
100 10
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,18 @@
|
|||
## z:\Chao\src\4095_xmly\test\in.txt
|
||||
2020/04/18 ÖÜÁù 8:28:39.27
|
||||
2
|
||||
-----------------------------------------------
|
||||
Process exited after 240 ms with return value 0
|
||||
|
||||
## z:\Chao\src\4095_xmly\test\in2.txt
|
||||
2020/04/18 ÖÜÁù 8:28:39.27
|
||||
57
|
||||
-----------------------------------------------
|
||||
Process exited after 120 ms with return value 0
|
||||
|
||||
## z:\Chao\src\4095_xmly\test\in3.txt
|
||||
2020/04/18 ÖÜÁù 8:28:39.27
|
||||
82
|
||||
-----------------------------------------------
|
||||
Process exited after 160 ms with return value 0
|
||||
|
Loading…
Reference in New Issue