이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAX = 10000005;
int x[MAX], y[MAX], ord[MAX];
bool cmp(int i, int j) {
return make_pair(x[i], -y[i]) < make_pair(x[j], -y[j]);
}
int readint(){
int x=0,f=1; char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int main() {
int n, a, b, i;
n = readint();
for (i = 0; i < n; i++) {
a = readint();
b = readint();
x[i] = a - b;
y[i] = a + b;
ord[i] = i;
}
sort(ord, ord + n, cmp);
int ans = 0, mx = -1;
for (int i = 0; i < n; i++) {
if (mx < y[ord[i]]) {
ans += 1;
mx = y[ord[i]];
}
}
printf("%d\n", ans);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |