Problem:


Score : 200 points

Problem Statement

In a factory, there are N robots placed on a number line.
Robot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative.

We want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect.
Here, for each i (1 \leq i \leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints.

Find the maximum number of robots that we can keep.

Constraints

1 \leq N \leq 100,000

0 \leq X_i \leq 10^9 (1 \leq i \leq N)

1 \leq L_i \leq 10^9 (1 \leq i \leq N)

If i \neq j, X_i \neq X_j.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
X_1 L_1
X_2 L_2
\vdots
X_N L_N

Output

Print the maximum number of robots that we can keep.

Sample Input 1

4
2 4
4 3
9 3
100 5

Sample Output 1

3

By removing Robot 2, we can keep the other three robots.

Sample Input 2

2
8 20
1 10

Sample Output 2

1

Sample Input 3

5
10 1
2 1
4 1
6 1
8 1

Sample Output 3

5



Sample input:
4
2 4
4 3
9 3
100 5


Sample output:
3

Submission status: Wrong Answer

Solution code:
N = int(input())
X = [0]*N
L = [0]*N
for i in range(N):
    X[i], L[i] = map(int, input().split())

indexes = [i for i in range(N)]
sorted_indexes = sorted(indexes, key=lambda i: X[i])

count = 0
if N == 2:
    for i in range(N-1):
        if X[sorted_indexes[i]] + L[sorted_indexes[i]] < X[sorted_indexes[i+1]] - L[sorted_indexes[i+1]]:
            continue
        else:
            if L[sorted_indexes[i]] >= L[sorted_indexes[i+1]]:
                L[sorted_indexes[i]] = 0
                count = 1
            else:
                L[sorted_indexes[i+1]] = 0
                count = 1
else:
    for i in range(N-2):
        if X[sorted_indexes[i]] + L[sorted_indexes[i]] < X[sorted_indexes[i+1]] - L[sorted_indexes[i+1]]:
            continue
        else:
            if X[sorted_indexes[i]] + L[sorted_indexes[i]] > X[sorted_indexes[i+2]] - L[sorted_indexes[i+2]]:
                L[sorted_indexes[i]] = 0
                count = 1

            if X[sorted_indexes[i+1]] + L[sorted_indexes[i+1]] > X[sorted_indexes[i+2]] - L[sorted_indexes[i+2]]:
                L[sorted_indexes[i+1]] = 0
                count = 1

print(N - count)

Submission status: Wrong Answer

Solution code:
N=int(input())
X=[]
x={}
for i in range(N):
    a,b=map(int,list(input().split(" ")))
    X.append(a+b)
    x[a+b]=a-b
X.sort()
D={}
D[0]=1
exe=[0]
for i in range(1,N):
    k=X[i]
    if x[k]<X[exe[-1]]:
        D[i]=D[exe[-1]]
    else:
        D[i]=D[exe[-1]]+1
        exe.append(i)
print(len(exe))

Submission status: Wrong Answer

Solution code:
INF = float("inf") #const

def main():
    n = int(input())
    ls = [list(map(int,input().split())) for _ in range(n)]
    #start ls[i][0] - ls[i][1]. goal ls[i][0] + ls[i][1]
    ls = sorted(ls,key = lambda x:x[0])

    ans = 0; t = -INF
    for i in range(n):
        if t <= ls[i][0] - ls[i][1]:
            ans += 1
            t = ls[i][0] + ls[i][1]
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
INF = float("inf") #const

def main():
    n = int(input())
    ls = [list(map(int,input().split())) for _ in range(n)]
    #start ls[i][0] - ls[i][1]. goal ls[i][0] + ls[i][1]
    ls = sorted(ls,key = lambda x:x[0])
    print(ls)

    ans = 0; t = -INF
    for i in range(n):
        if t <= ls[i][0] - ls[i][1]:
            ans += 1
            t = ls[i][0] + ls[i][1]
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    ls = [list(map(int,input().split())) for _ in range(n)]
    #start ls[i][0] - ls[i][1]. goal ls[i][0] + ls[i][1]
    ls = sorted(ls,key = lambda x:x[0])

    ans = 1; t = ls[0][0] + ls[0][1] - 1
    for i in range(1,n):
        if t < ls[i][0] - ls[i][1]:
            ans += 1
            t = ls[i][0] + ls[i][1] - 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    ls = [list(map(int,input().split())) for _ in range(n)]
    #start ls[i][0] - ls[i][1]. goal ls[i][0] + ls[i][1]
    ls = sorted(ls,key = lambda x:x[0])

    ans = 1; t = ls[0][0] + ls[0][1]
    for i in range(1,n):
        if t <= ls[i][0] - ls[i][1]:
            ans += 1
            t = ls[i][0] + ls[i][1]
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

N = int(input())
R = [0]*N
for i in range(N):
    X_i, L_i = map(int, input().split())
    R[i] = (X_i-L_i+1,X_i+L_i-1)
R.sort(key=itemgetter(1))

ans, loc = 0, -(float('inf'))
for i in range(len(R)):
    if loc < R[i][0]:
        ans += 1
        loc = R[i][1]
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.buffer.readline

L=[]
for _ in range(int(input())):
  x,l=map(int,input().split())
  L.append((x-l,x+l))

L.sort(key=lambda x:x[1])
ans=0
cur=-1
for a,b in L:
  if a>=cur:
    cur=b
    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

xl = []

for i in range(n):
    x,l = map(int,input().split())
    xl.append([x+l,x-l])
xl.sort()
ans = -10**10
count = 0
for j in range(n):
    if xl[i][1] > ans:
        count +=1
        ans = xl[i][0]
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())

xl = []

for i in range(n):
    x,l = map(int,input().split())
    xl.append([x-l,x+l])
xl.sort()
ans = -10**10
count = 0
for j in range(n):
    if xl[i][1] > ans:
        count +=1
        ans = xl[i][0]
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())

robo = [[int(zz) for zz in input().split()] for _ in range(N)]
robo.sort()

arm = [[0,0] for _ in range(N)]
for i in range(N):
    arm[i][0] = robo[i][0]-robo[i][1]+1
    arm[i][1] = robo[i][0]+robo[i][1]-1

ans = N
r = arm[0][1]
for i in range(1,N):
    if r < arm[i][0]:
        r = arm[i][1]
    else:
        ans -= 1
        if i+1 < N and r < arm[i+1][0]:
            r = arm[i][1]
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

robo = [[int(zz) for zz in input().split()] for _ in range(N)]
robo.sort()

arm = [[0,0] for _ in range(N)]
for i in range(N):
    arm[i][0] = robo[i][0]-robo[i][1]+1
    arm[i][1] = robo[i][0]+robo[i][1]-1

ans = N
r = arm[0][1]
for i in range(1,N):
    if r < arm[i][0]:
        r = arm[i][1]
    else:
        ans -= 1

print(ans)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
n = int(input())
xl = [list(map(int, input().split())) for _ in range(n)]
xl.sort(key=itemgetter(0))

annoying_count = 0
for i in range(n-1):
  prev_x, prev_l = xl[i]
  next_x, next_l = xl[i+1]
  if next_x - next_l + 1 <= prev_x + prev_l - 1:
    # かぶったのでカウント
    xl[i+1] = [next_x, 0]
    annoying_count += 1
  
print(n - annoying_count)

Submission status: Wrong Answer

Solution code:
N = int(input())
R = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x:x[0])

remain = list(range(N))
ans = N
left = 0
i = 1
while i < N:
  x_l, length_l = R[left]
  x, length = R[i]
  if x-x_l < length_l+length:
    ans -= 1
  else:
    left = i
  i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
R = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x:x[0])

remain = list(range(N))
left = 0
i = 1
while i < N:
  x_l, length_l = R[left]
  x, length = R[i]
  if x-x_l < length_l+length:
    remain.pop(remain.index(i))
  else:
    left = i
  i += 1
print(len(remain))

Submission status: Wrong Answer

Solution code:
N = int(input())
R = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x:x[0])

remain = list(range(N))
left = 0
i = 1
while i < N:
  print(remain)
  x_l, length_l = R[left]
  x, length = R[i]
  if x-x_l < length_l+length:
    remain.pop(remain.index(i))
  else:
    left = i
  i += 1
print(len(remain))

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [list(map(int, input().split())) for i in range(n)]

s = []
f = []
res = 1

for i in range(n):
    s.append(l[i][0]-l[i][1])
    f.append([l[i][0]+l[i][1], i])
    
f = sorted(f)
#print(f)

m = f[0][0]
for i in range(1, n):
    if s[f[i][1]] >= m:
        res += 1
    
print(res)

Submission status: Wrong Answer

Solution code:
times = int(input())

robots = [map(int , input().split()) for i in range(times)]
print(robots.sort)

Submission status: Wrong Answer

Solution code:
N=int(input())
A = [list(map(int,input().split())) for i in list(range(N))]
B = [[i[0]+i[1], i[0]-i[1]] for i in A]
B.sort()
prev=B[0]
cnt=N
for i in range(1,N):
  if prev[0]<B[i][1]:
    cnt-=1
  else:
    prev=B[i]
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [list(map(int,input().split())) for i in list(range(N))]
B = [[i[0]-i[1], i[0]+i[1]] for i in A]
B.sort()
prev=B[0]
cnt=N
for i in range(1,N):
  if prev[1]>B[i][0]:
    cnt-=1
  else:
    prev=B[i]
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
robots = []
for _ in range(n):
  x,l = map(int,input().split())
  a,b = x-l,x+l
  robots.append((a,b))
robots.sort(key = lambda x:x[1])

ex_a = -1
count = 0

for a,b in robots:
  if b >= ex_a:
    ex_a = a
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
robots = []
for _ in range(n):
  x,l = map(int,input().split())
  a,b = x-l,x+l
  robots.append((a,b))
robots.sort(key = lambda x:x[1])

ex_a = ex_b = -1
count = 0

for a,b in robots:
  if a > ex_b:
    ex_b = b
    count += 1
  else:
    continue
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
robots = []
for _ in range(n):
  x,l = map(int,input().split())
  a,b = x-l,x+l
  robots.append((a,b))
robots.sort(key = lambda x:x[1])

ex_a = ex_b = -1
count = 0

for a,b in robots:
  if a >= ex_b:
    ex_b = b
    count += 1
  else:
    continue
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
TS = []
for _ in range(N):
    X,L = map(int, input().split())
    TS.append([X,L])
 
mlist=[]
for i in range(N):
    mlist.append([TS[i][0] - TS[i][1], TS[i][0] + TS[i][1]])
 
mlist.sort()
print(mlist)

cur = -10**10
ans=0
for i in range(N):
    if mlist[i][0] >= cur:
        ans+=1
        cur = mlist[i][1]
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = []
for _ in range(n):
  x, l= list(input().split(" "))
  p_d = int(x) + int(l)
  m_d = int(x) - int(l)
  lis.append([m_d, p_d])

lis.sort()
a = -10 ** 10
x = 0

for b in range(n):
  if lis[b][1] >= a:
    x += 1
    a = lis[b][0]

print(x)

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = []
for _ in range(n):
  x, l= list(input().split(" "))
  p_d = int(x) + int(l)
  m_d = int(x) - int(l)
  lis.append([m_d, p_d])

lis.sort()
a = -10 ** 10
x = 0

for b in range(n):
  if lis[b][0] >= a:
    x += 1
    a = lis[b][1]

print(x)

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = []
for _ in range(n):
  x, l= list(input().split(" "))
  p_d = int(x) + int(l)
  m_d = int(x) - int(l)
  lis.append([m_d, p_d])

lis.sort()
a = -10 ** 10
x = 0

for b in range(n):
  if lis[b][0] >= a:
    x += 1
    a = lis[b][1]

print(lis)

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = []
lis2 = []
for _ in range(n):
  x, l= list(input().split(" "))
  p_d = int(x) + int(l)
  m_d = int(x) - int(l)
  lis.append([m_d, p_d])

lis.sort()
a = -10 ** 10
x = 0

for b in range(n):
  if lis[b][0] >= a:
    x += 1
    a = lis[b][1]

print(x)

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = []
lis2 = []
for _ in range(n):
  x, l= list(input().split(" "))
  p_d = int(x) + int(l)
  m_d = int(x) - int(l)
  lis.append([m_d, p_d])

lis.sort
a = -10 ** 10
x = 0

for b in range(n):
  if lis[b][0] >= a:
    x += 1
    a = lis[b][1]

print(x)

Submission status: Wrong Answer

Solution code:
N = int(input())

L = [list(map(int, input().split())) for _ in range(N)]

for i in range(len(L)):

    L[i][0] = L[i][0] - L[i][1]
    L[i][1] = L[i][0] + L[i][1]
Q = L
Q .sort(key=lambda x: x[1])

a = 0
check = Q[0][1]
for i in range(1,N):
    if check <= Q[i][0] :
        check = Q[i][1]
    else:
        a += 1

print(N-a)

Submission status: Wrong Answer

Solution code:
N = int(input())

L = [list(map(int, input().split())) for _ in range(N)]

S = []
for i in range(len(L)):

    L[i][0] = L[i][0] - L[i][1]
    L[i][1] = L[i][0] + L[i][1]
Q =sorted(L)

a = 0
check = Q[0][1]
for i in range(1,N):
    if check <= Q[i][0] :
        check = Q[i][1]
    else:
        a += 1

print(N-a)

Submission status: Wrong Answer

Solution code:
N = int(input())

L = [list(map(int, input().split())) for _ in range(N)]

S = []
for i in range(len(L)):
    S.append([L[i][0] - L[i][1],L[i][0] + L[i][1]])
    #L[i][0] = L[i][0] - L[i][1]
    #L[i][1] = L[i][0] + L[i][1]
Q =sorted(S)

a = 0
check = Q[0][1]
for i in range(1,N):
    if check <= Q[i][0] :
        check = Q[i][1]
    else:
        a += 1

print(N-a)

Submission status: Wrong Answer

Solution code:
N = int(input())

L = [list(map(int, input().split())) for _ in range(N)]

S = []
for i in range(len(L)):
    S.append(sorted([L[i][0] - L[i][1],L[i][0] + L[i][1]]))
    #L[i][0] = L[i][0] - L[i][1]
    #L[i][1] = L[i][0] + L[i][1]
Q =sorted(S)

a = 0
check = Q[0][1]
for i in range(1,N):
    if check <= Q[i][0] :
        check = Q[i][1]
    else:
        a += 1

print(N-a)

Submission status: Wrong Answer

Solution code:
N = int(input())

L = [[int(x) for x in input().split()] for x in range(N)]

S = []
for i in range(len(L)):
    S.append(sorted([L[i][0] - L[i][1],L[i][0] + L[i][1]]))
    #L[i][0] = L[i][0] - L[i][1]
    #L[i][1] = L[i][0] + L[i][1]
Q =sorted(S)

a = 0
check = Q[0][1]
for i in range(1,N):
    if check <= Q[i][0] :
        check = Q[i][1]
    else:
        a += 1

print(N-a)

Submission status: Wrong Answer

Solution code:
N = int(input())

L = [[int(x) for x in input().split()] for x in range(N)]

S = []
for i in range(len(L)):
    S.append(sorted([L[i][0] - L[i][1],L[i][0] + L[i][1]]))
    #L[i][0] = L[i][0] - L[i][1]
    #L[i][1] = L[i][0] + L[i][1]
Q =sorted(S)

a = 0
check = Q[0][1]
for i in range(1,len(Q)):
    if check <= Q[i][0] :
        check = Q[i][1]
    else:
        a += 1

print(N-a)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = []

L = [[int(x) for x in input().split()] for x in range(N)]

S = []
for i in range(len(L)):
    S.append(sorted([L[i][0] - L[i][1],L[i][0] + L[i][1]]))
    #L[i][0] = L[i][0] - L[i][1]
    #L[i][1] = L[i][0] + L[i][1]
Q =sorted(S)

a = 0
check = Q[0][1]
for i in range(1,len(Q)):
    if check <= Q[i][0] :
        check = Q[i][1]
    else:
        a += 1

print(N-a)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = []

L = [[int(x) for x in input().split()] for x in range(N)]

S = []
for i in range(len(L)):
    S.append(sorted([L[i][0] - L[i][1],L[i][0] + L[i][1]]))
    #L[i][0] = L[i][0] - L[i][1]
    #L[i][1] = L[i][0] + L[i][1]
Q =sorted(S)
print(Q)
a = 0
check = Q[0][1]
for i in range(1,len(Q)):
    if check <= Q[i][0] :
        check = Q[i][1]
    else:
        a += 1

print(N-a)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = []

L = [[int(x) for x in input().split()] for x in range(N)]

S = []
for i in range(len(L)):
    S.append(sorted([L[i][0] - L[i][1],L[i][0] + L[i][1]]))
    #L[i][0] = L[i][0] - L[i][1]
    #L[i][1] = L[i][0] + L[i][1]
Q =sorted(S)
print(Q)
a = 1
check = max(Q[0])
for i in range(0,len(Q)-1):
    if min(Q[i+1]) >=check :
        check = min(Q[i+1])
        a+=1

print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = []

L = [[int(x) for x in input().split()] for x in range(N)]

S = []
for i in range(len(L)):
    S.append(sorted([L[i][0] - L[i][1],L[i][0] + L[i][1]]))
    #L[i][0] = L[i][0] - L[i][1]
    #L[i][1] = L[i][0] + L[i][1]
Q =sorted(S)
a = 1
check = max(Q[0])
for i in range(0,len(Q)-1):
    if min(Q[i+1]) >=check :
        check = min(Q[i+1])
        a+=1
    else:
        check = max(Q[i+1])
print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = []

L = [[int(x) for x in input().split()] for x in range(N)]

S = []
for i in range(len(L)):
    S.append(sorted([L[i][0] - L[i][1],L[i][0] + L[i][1]]))
    #L[i][0] = L[i][0] - L[i][1]
    #L[i][1] = L[i][0] + L[i][1]
Q =sorted(S)
a = 1
check = max(Q[0])
print(Q)
for i in range(0,len(Q)-1):
    if min(Q[i+1]) >=check :
        check = min(Q[i+1])
        a+=1
    else:
        check = max(Q[i+1])
print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = []

L = [[int(x) for x in input().split()] for x in range(N)]


for i in range(len(L)):
    L[i][0] = L[i][0] - L[i][1]
    L[i][1] = L[i][0] + L[i][1]
S =[]
Q = sorted(L)
a = 1
check = 0
print(Q)
for i in range(0,len(Q)-1):
    check = min(Q[i])
    if min(Q[i+1]) >=check :
        check = min(Q[i+1])
        a+=1
print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = []

L = [[int(x) for x in input().split()] for x in range(N)]


for i in range(len(L)):
    L[i][0] = L[i][0] - L[i][1]
    L[i][1] = L[i][0] + L[i][1]
S =[]
Q = sorted(L)
a = 1
check = 0

for i in range(0,len(Q)-1):
    check = Q[i][1]
    if Q[i+1][0] >=check :
        check = Q[i+1][0]
        a+=1
print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = []

L = [[int(x) for x in input().split()] for x in range(N)]


for i in range(len(L)):
    L[i][0] = L[i][0] - L[i][1]
    L[i][1] = L[i][0] + L[i][1]
S =[]
Q = sorted(L)
for i in range(0,len(Q)-1):
    if Q[i+1][0] >=Q[i][1] :
        S.append([Q[i][0],Q[i][1]])
print(len(S)+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = []
for i in range(N):
    x = [int(x) for x in input().split()]
    L.append(x)
for i in range(len(L)):
    L[i][0] = L[i][0] - L[i][1]
    L[i][1] = L[i][0] + L[i][1]
S =[]
Q = sorted(L)
for i in range(0,len(Q)-1):
    if Q[i+1][0] >=Q[i][1] :
        S.append([Q[i][0],Q[i][1]])
        print(S)
print(len(S)+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
XL = [list(map(int, input().split())) for _ in range(N)]
RL = [[0, 0] for _ in range(N)]
for i in range(N):
    left = XL[i][0] - XL[i][1] + 1
    right = XL[i][0] + XL[i][1] - 1
    RL[i][0] = left
    RL[i][1] = right

RL.sort(key=lambda x: x[1])
now_right = RL[0][1]
cnt = 0
for i in range(1, N):
    if now_right <= RL[i][0]:
        now_right = RL[i][1]
    else:
        cnt += 1
print(N - cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
LR = [None] * n
for i in range(n):
    x, l = map(int, input().split())
    LR[i] = (x - l, x + l)
LR.sort(key=lambda lr: (-lr[1], -lr[0]))
count = 0
cur = LR[0][0]
for l, r in LR[1:]:
    if cur < r:
        count += 1
    else:
        cur = l
print(n - count)

Submission status: Wrong Answer

Solution code:
n = int(input())
LR = [None] * n
for i in range(n):
    x, l = map(int, input().split())
    LR[i] = (x - l, x + l)
LR.sort(key=lambda lr: -lr[1])
count = 0
cur = LR[0][0]
for l, r in LR[1:]:
    if cur < r:
        count += 1
    else:
        cur = l
print(n - count)

Submission status: Wrong Answer

Solution code:
def solve(n, XL):
    blocked = [0] * n
    total = 0
    for i in range(n):
        ax, al = XL[i]
        for j in range(i + 1, n):
            bx, bl = XL[j]
            if ax - al < bx - bl < ax + al or ax - al < bx + bl < ax + al:
                blocked[i] += 1
                blocked[j] += 1
                total += 1
    blocked.sort(reverse=True)
    count = 0
    for num in blocked:
        total -= num
        count += 1
        if total == 0:
            break
    return n - count

_n = int(input())
_XL = [list(map(int, input().split())) for _ in range(_n)]
print(solve(_n, _XL))

Submission status: Wrong Answer

Solution code:
N = int(input())
TS = []
for _ in range(N):
    X,L = map(int, input().split())
    TS.append([X,L])

mlist=[]
for i in range(N):
#    mlist.append([TS[i][0] + TS[i][1], TS[i][0] - TS[i][1]])
    mlist.append([TS[i][0] + TS[i][1], TS[i][0] - TS[i][1]])

mlist.sort()

cur = -10*10
ans=0
for i in range(N):
    if mlist[i][1] >= cur:
        ans+=1
        cur = mlist[i][0]
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
TS = []
for _ in range(N):
    X,L = map(int, input().split())
    TS.append([X,L])

mlist=[]
for i in range(N):
    mlist.append([TS[i][0] + TS[i][1], TS[i][0] - TS[i][1]])

mlist.sort()

cur = -10*10
ans=0
for i in range(N):
    if mlist[i][1] >= cur:
        ans+=1
        cur = mlist[i][0]
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
TS = []
for _ in range(N):
    X,L = map(int, input().split())
    TS.append([X,L])

min_list=[]
for i in range(N):
    min_list.append([TS[i][0] + TS[i][1], TS[i][0] - TS[i][1]])

min_list.sort()

ans=0
current_min = -10*10
for i in range(N):
    if min_list[i][1] >= current_min:
        ans+=1
        current_min = min_list[i][0]
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = []
for _ in range(N):
    X,L = map(int, input().split())
    S.append([X,L])

min_list=[]
for i in range(N):
    min_list.append((S[i][0] + S[i][1], S[i][0] - S[i][1]))

min_list.sort()

ans=0
current_min = -10*10
for i in range(N):
    if min_list[i][1] >= current_min:
        ans+=1
        current_min = min_list[i][0]
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = []
for _ in range(N):
    D = list(map(int, input().split()))
    S.append(D)

min_list=[]
for i in range(N):
    min_list.append((S[i][0] + S[i][1], S[i][0] - S[i][1]))

min_list.sort()

ans=0
current_min = -10*10
for i in range(N):
    if min_list[i][1] >= current_min:
        ans+=1
        current_min = min_list[i][0]
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = []
for _ in range(N):
    D = list(map(int, input().split()))
    S.append(D)

min_list=[]
for i in range(N):
    min_list.append([S[i][0] + S[i][1], S[i][0] - S[i][1]])

min_list.sort()

ans=0
current_min = -10*10
for i in range(N):
    if min_list[i][1] >= current_min:
        ans+=1
        current_min = min_list[i][0]
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = []
for _ in range(N):
    D = list(map(int, input().split()))
    S.append(D)

min_list=[]
for i in range(N):
    min_list.append([S[i][0] - S[i][1], S[i][0] + S[i][1]])
min_list.sort(key=lambda x:x[1])

ans=0
current_min = -10*10
for i in range(N):
    if min_list[i][0] >= current_min:
        ans+=1
        current_min = min_list[i][1]
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = []
for _ in range(N):
    D = list(map(int, input().split()))
    S.append(D)

min_list=[]
for i in range(N):
    min_list.append([S[i][0],S[i][1],S[i][0] + S[i][1]])
min_list.sort(key=lambda x:x[2])

ans=0
current_min = -10*10
for i in range(N):
    if min_list[i][0] - min_list[i][1] >= current_min:
        ans+=1
        current_min = min_list[i][2]
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
XL =[list(map(int, input().split())) for _ in range(N)]
LR = [[XL[i][0] - XL[i][1], XL[i][0] + XL[i][1]] for i in range(N)]
LR.sort()

cp = LR[0][1]

ans = 0

for i in range(1,N):
	if LR[i][0] < cp:
		ans += 1
	else:
		cp = LR[i][1]
print(N-ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
XL =[list(map(int, input().split())) for _ in range(N)]

XL.sort()

cp = XL[0][0] + XL[0][1]

ans = 1
for i in range(1,N):
	if XL[i][0] - XL[i][1] < cp:
		continue
	else:
		ans += 1
		cp = XL[i][0] +XL[i][1]

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
ar = []
mi = 0
mx = 0
count = 1
for i in range(n):
    br = list(map(int,input().split(" ")))
    ar.append(br)
ar.sort()
for i,r in enumerate(ar):
    if i == 0:
        mx = r[0] + r[1]
    else:
        if mx <= r[0] - r[1]:
            mx = r[0] + r[1]
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
def solve():
    N = int(input())
    C = []
    for _ in range(N):
        a, b = list(map(int, input().split()))
        C.append((a-b, a+b))

    C.sort()
    
    c = 0
    cur = -float('inf')
    for i in range(N):
        if cur <= C[i][0]:
            c += 1
            cur = C[i][1]

    return c

print(solve())

Submission status: Wrong Answer

Solution code:
def solve():
    N = int(input())
    C = []
    for _ in range(N):
        a, b = list(map(int, input().split()))
        C.append((a-b+1, a+b-1))

    C.sort()

    for i in range(N-1):
        for j in range(len(C)-1):
            if C[j][1] >= C[j+1][0]: 
                C.pop(j+1)
                break

    return len(C)

print(solve())

Submission status: Wrong Answer

Solution code:
num = int(input())
lista=[]
ans = 0
for i in range(num):
  j= list(map(int, input().split()))
  a=j[0]-j[1]
  b=j[0]+j[1]
  lista.append([a,b])
lista.sort(key=lambda x: x[1])
print(lista)

def list_func(x):
  global ans
  xa=[i for i in x if i[0]>=x[0][1]]
  ans+=1
  return xa
while(len(lista)):
  lista=list_func(lista)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
L = []
for _ in range(n):
    x, l = LI()
    L += [(x - l, x + l)]

L.sort()
ret = -INF
cnt = 0
for i in range(n):
    left, right = L[i]
    if ret <= left:
        ret = right
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
L = [(INF, INF)]
for _ in range(n):
    x, l = LI()
    L += [(x - l, x + l)]

L.sort()
ret = -INF
cnt = 0
for i in range(n):
    left, right = L[i]
    if ret <= left:
        ret = right
        cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n = int(input())
x = [0]*n
l = [0]*n
for i in range(n):
    x[i],l[i] = map(int,input().split())
#print(x,l)
x,l = zip(*sorted(zip(x,l)))
#print(x,l)
break_flag = 1
cnt = 0
right = -(10**9+1)
i = 0
while break_flag:
    next_rihgt = 10**9+1
    cnt += 1
    while True:
        if right <= x[i] - l[i]:
            if next_rihgt > x[i]+l[i]:
                #print(i,cnt,right,next_rihgt)
                next_rihgt = x[i]+l[i]
        if next_rihgt < x[i]:#もう更新の目はないので
            #print(i,cnt,right,next_rihgt)
            #cnt += 1
            right = next_rihgt
            if i == n: break_flag = 0
            break
        i += 1
        if i == n: 
            break_flag = 0
            #cnt += 1
            break
print(cnt)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n = int(input())
x = [0]*n
l = [0]*n
for i in range(n):
    x[i],l[i] = map(int,input().split())
#print(x,l)
x,l = zip(*sorted(zip(x,l)))
#print(x,l)
break_flag = 1
cnt = 0
right = -(10**9+1)
i = 0
while break_flag:
    next_rihgt = 10**9+1
    while True:
        if right <= x[i] - l[i]:
            if next_rihgt > x[i]+l[i]:
                #print(i,cnt,right,next_rihgt)
                next_rihgt = x[i]+l[i]
        if next_rihgt < x[i]:#もう更新の目はないので
            #print(i,cnt,right,next_rihgt)
            cnt += 1
            right = next_rihgt
            if i == n: break_flag = 0
            break
        i += 1
        if i == n: 
            break_flag = 0
            cnt += 1
            break
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
robots = [list(map(int,input().split())) for _ in range(n)]
robots.sort()
current = -float('inf')
ans = n
for x,l in robots:
    if x - l < current:
        ans -= 1
    else:
        current = x + l - 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
robots = [list(map(int,input().split())) for _ in range(n)]
robots.sort()
current = -float('inf')
ans = n
for x,l in robots:
    if x - l <= current:
        ans -= 1
    else:
        current = x + l - 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
robots = [list(map(int,input().split())) for _ in range(n)]
robots.sort()
current = -float('inf')
ans = n
for x,l in robots:
    if x - l < current:
        ans -= 1
    else:
        current = x + l
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
XL = [list(map(int, input().split())) for _ in range(N)]

# アームが伸びる範囲に置き換える
a = []
for i in range(N):
    a.append([XL[i][0] - XL[i][1], XL[i][0] + XL[i][1]])
# アームが届く最大座標でソートする
a = sorted(a, key=lambda x: x[1])

count = 0
diff = 0
for i in range(1, N):
    if a[i-1-diff][1] > a[i][0]:
        count += 1
        a[i][0] = -float('inf')
        a[i][1] = -float('inf')
        diff = 1
    else:
        diff = 0
print(N-count)

Submission status: Wrong Answer

Solution code:
N = int(input())
XL = [list(map(int, input().split())) for _ in range(N)]

# アームが伸びる範囲に置き換える
a = []
for i in range(N):
    a.append([XL[i][0] - XL[i][1], XL[i][0] + XL[i][1]])
# アームが届く最大座標でソートする
a = sorted(a, key=lambda x: x[1])

count = 0
diff = 0
for i in range(1, N):
    if a[i-1-diff][1] > a[i][0]:
        count += 1
        diff = 1
    else:
        diff = 0
print(N-count)

Submission status: Wrong Answer

Solution code:
N=int(input())

contain=[]

contain=[list(map(int,input().split())) for i in range(N)]

    
for i in range(len(contain)-1):
    if contain[i][0]>contain[i+1][0]:
        contain[i],contain[i+1]=contain[i+1],contain[i]
    
judge=True
while judge:
    for i in range(len(contain)-1):
        if contain[i][0]+contain[i][1] > contain[i+1][0]-contain[i+1][1]:
            contain.remove(contain[i+1])
            break
        elif i==len(contain)-2:
            judge=False
            break

print(len(contain))