#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (1000005)
int readInt()
{
int x = 0;
char ch=getchar_unlocked();
bool s=1;
while(ch<'0'||ch>'9'){if(ch=='-')s=0;ch=getchar_unlocked();}
while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar_unlocked();}
return s?x:-x;
}
int main() {
ios_base::sync_with_stdio(false);cin.tie(0);
ll N;
N = readInt();
pair<int,int> arr[N];
stack<pair<int,int>> s;
for(ll i = 0;i < N;i++){
ll X,Y;
X = readInt();
Y = readInt();
arr[i].first = X;
arr[i].second = Y;
}
sort(arr,arr + N);
for(ll i = 0;i < N;i++){
if(s.size() == 0){
s.push(make_pair(arr[i].first,arr[i].second));
}else{
if(abs(s.top().first - arr[i].first) <= (s.top().second - arr[i].second)){
}else if(abs(arr[i].first - s.top().first) <= (arr[i].second - s.top().second)){
while(s.size() != 0 && abs(arr[i].first - s.top().first) <=
(arr[i].second - s.top().second)){
s.pop();
}
s.push(make_pair(arr[i].first,arr[i].second));
}else{
s.push(make_pair(arr[i].first,arr[i].second));
}
}
}
cout<<s.size()<<'\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
687 ms |
262144 KB |
Output is correct |
2 |
Correct |
703 ms |
262144 KB |
Output is correct |
3 |
Correct |
732 ms |
261444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
456 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
456 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
464 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
456 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
464 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
352 KB |
Output is correct |
12 |
Correct |
1 ms |
352 KB |
Output is correct |
13 |
Correct |
1 ms |
352 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
456 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
464 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
352 KB |
Output is correct |
12 |
Correct |
1 ms |
352 KB |
Output is correct |
13 |
Correct |
1 ms |
352 KB |
Output is correct |
14 |
Correct |
15 ms |
5460 KB |
Output is correct |
15 |
Correct |
14 ms |
5084 KB |
Output is correct |
16 |
Correct |
15 ms |
5336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
665 ms |
225716 KB |
Output is correct |
2 |
Correct |
664 ms |
225772 KB |
Output is correct |
3 |
Correct |
633 ms |
220024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
687 ms |
262144 KB |
Output is correct |
2 |
Correct |
703 ms |
262144 KB |
Output is correct |
3 |
Correct |
732 ms |
261444 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
456 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
464 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
352 KB |
Output is correct |
15 |
Correct |
1 ms |
352 KB |
Output is correct |
16 |
Correct |
1 ms |
352 KB |
Output is correct |
17 |
Correct |
15 ms |
5460 KB |
Output is correct |
18 |
Correct |
14 ms |
5084 KB |
Output is correct |
19 |
Correct |
15 ms |
5336 KB |
Output is correct |
20 |
Correct |
665 ms |
225716 KB |
Output is correct |
21 |
Correct |
664 ms |
225772 KB |
Output is correct |
22 |
Correct |
633 ms |
220024 KB |
Output is correct |
23 |
Correct |
753 ms |
246924 KB |
Output is correct |
24 |
Correct |
690 ms |
227988 KB |
Output is correct |
25 |
Correct |
693 ms |
212332 KB |
Output is correct |