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())

contain=[]

for i in range(N):
    li=list(map(int, input().split()))
    contain.append(li)

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]
    
for i in range(N):
    for j in range(len(contain)-1):
        if contain[j][0]+contain[j][1] > contain[j+1][0]-contain[j+1][1]:
            contain.remove(contain[j+1])
            break

print(len(contain))

Submission status: Wrong Answer

Solution code:
N=int(input())

contain=[]

for i in range(N):
    li=list(map(int, input().split()))
    contain.append(li)

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

print(len(contain))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000000)

xls = []
removes = []
n = int(input())
for i in range(n):
    x, l = input().split()
    xls.append((int(x), int(l)))
    removes.append(False)
xls.sort()

def resolve(i):
    xi, li = xls[i]
    ri = removes[i]

    for j in range(i+1, len(xls)):
        xj, lj = xls[j]
        rj = removes[j]
        if not rj and xi + li > xj - lj:
            removes[j] = True

def main():
    res = 0
    for i in range(len(xls)):
        if not removes[i]:
            resolve(i)
    print(removes.count(False))

main()

Submission status: Wrong Answer

Solution code:
xls = []
removes = []
n = int(input())
for i in range(n):
    x, l = input().split()
    xls.append((int(x), int(l)))
    removes.append(False)
xls.sort()

def resolve(i):
    xi, li = xls[i]
    ri = removes[i]

    for j in range(i+1, len(xls)):
        xj, lj = xls[j]
        rj = removes[j]
        if not rj and xi + li > xj - lj:
            removes[j] = True

def main():
    res = 0
    for i in range(len(xls)):
        if not removes[i]:
            resolve(i)
    print(removes.count(False))

main()

Submission status: Wrong Answer

Solution code:
length = int(input())
target = []
for i in range(length):
    s, e = map(int, input().split(" "))
    target.append([s - e, s + e])
target.sort(key = lambda x: x[0], reverse =  True)
target.sort(key = lambda x: x[1])
answer = 0
before_s, before_e = -float("inf"), -float("inf")
# print(target)
for s, e in target:
    # print(before_s, before_e, s, e)
    if before_s < s < before_e or before_s < e < before_e or s < before_e < e:
        # print(1, before_s, before_e, s, e)
        answer += 1
    else:
        before_s = s
        before_e = e
print(length - answer)

Submission status: Wrong Answer

Solution code:
length = int(input())
target = []
for i in range(length):
    s, e = map(int, input().split(" "))
    target.append([s - e, s + e])
# target.sort(key = lambda x: x[0], reverse =  True)
target.sort(key = lambda x: x[1])
answer = 0
before_s, before_e = -float("inf"), -float("inf")
# print(target)
for s, e in target:
    # print(before_s, before_e, s, e)
    if before_s <= s < before_e or before_s < e <= before_e or s <= before_e <= e:
        # print(1, before_s, before_e, s, e)
        answer += 1
    else:
        before_s = s
        before_e = e
print(length - answer)

Submission status: Wrong Answer

Solution code:
length = int(input())
target = []
for i in range(length):
    s, e = map(int, input().split(" "))
    target.append([s - e, s + e])
# target.sort(key = lambda x: x[0], reverse =  True)
target.sort(key = lambda x: x[1])
answer = 0
before_s, before_e = -1, -1
# print(target)
for s, e in target:
    # print(before_s, before_e, s, e)
    if before_s <= s < before_e or before_s < e <= before_e or s <= before_e <= e:
        # print(1, before_s, before_e, s, e)
        answer += 1
    else:
        before_s = s

Submission status: Wrong Answer

Solution code:
length = int(input())
target = []
for i in range(length):
    s, e = map(int, input().split(" "))
    target.append([s - e, s + e])
target.sort(key = lambda x: x[1])
answer = 0
before_e = -1
for s, e in target:
    # print(before_e, s, e)
    if s < before_e:
        answer += 1
    else:
        before_e = e
print(length - answer)

Submission status: Wrong Answer

Solution code:
length = int(input())
target = []
for i in range(length):
    s, e = map(int, input().split(" "))
    target.append([s, s + e])
target.sort(key = lambda x: x[1])
answer = 0
before_e = -1
for s, e in target:
    # print(before_e, s, e)
    if s < before_e:
        answer += 1
    else:
        before_e = e
print(length - answer)

Submission status: Wrong Answer

Solution code:
length = int(input())
target = []
for i in range(length):
    s, e = map(int, input().split(" "))
    target.append([s, s + e])
target.sort(key = lambda x: x[1])
answer = 0
before_e = -1
for s, e in target:
    # print(before_e, s, e)
    if s <= before_e:
        answer += 1
    else:
        before_e = e
print(length - answer)

Submission status: Wrong Answer

Solution code:
length = int(input())
target = []
for i in range(length):
    s, e = map(int, input().split(" "))
    target.append([s, s + e])
target.sort(key = lambda x: x[1])
answer = 0
before_e = float("inf")
# print(target)
for s, e in target:
    # print(before_s, before_e, s, e)
    if s >= before_e:
        # print(1, before_s, before_e, s, e)
        answer += 1
    else:
        before_e = e
print(length - answer)

Submission status: Wrong Answer

Solution code:
length = int(input())
target = []
for i in range(length):
    s, e = map(int, input().split(" "))
    target.append([s, s + e])
# target.sort(key = lambda x: x[0], reverse =  True)
target.sort(key = lambda x: x[1])
answer = 0
before_s, before_e = -1, -1
# print(target)
for s, e in target:
    # print(before_s, before_e, s, e)
    if before_s <= s < before_e or before_s < e <= before_e or s <= before_e <= e:
        # print(1, before_s, before_e, s, e)
        answer += 1
    else:
        before_s = s
        before_e = e
print(length - answer)

Submission status: Wrong Answer

Solution code:
length = int(input())
target = []
for i in range(length):
    s, e = map(int, input().split(" "))
    target.append([s, s + e])
target.sort(key = lambda x: x[0], reverse =  True)
target.sort(key = lambda x: x[1])
answer = 0
before_s, before_e = -1, -1
# print(target)
for s, e in target:
    # print(before_s, before_e, s, e)
    if before_s <= s < before_e or before_s < e <= before_e or s <= before_e <= e:
        # print(1, before_s, before_e, s, e)
        answer += 1
    else:
        before_s = s
        before_e = e
print(length - answer)

Submission status: Wrong Answer

Solution code:
length = int(input())
target = []
for i in range(length):
    s, e = map(int, input().split(" "))
    target.append([s, s + e])
target.sort(key = lambda x: x[0], reverse =  True)
target.sort(key = lambda x: x[1])
answer = 0
before_s, before_e = -1, -1
# print(target)
for s, e in target:
    # print(before_s, before_e, s, e)
    if before_s <= s < before_e or before_s < e <= before_e or s <= before_e < e:
        # print(1, before_s, before_e, s, e)
        answer += 1
    else:
        before_s = s
        before_e = e
print(length - answer)

Submission status: Wrong Answer

Solution code:
length = int(input())
target = []
for i in range(length):
    s, e = map(int, input().split(" "))
    target.append([s, s + e])
target.sort(key = lambda x: x[0], reverse =  True)
target.sort(key = lambda x: x[1])
answer = 0
before_s, before_e = -1, -1
# print(target)
for s, e in target:
    if before_s <= s < before_e or before_s < e <= before_e:
        answer += 1
    else:
        before_s = s
        before_e = e
print(length - answer)

Submission status: Wrong Answer

Solution code:
length = int(input())
target = []
for i in range(length):
    s, e = map(int, input().split(" "))
    target.append([s, s + e])
target.sort(key = lambda x: x[0], reverse =  True)
target.sort(key = lambda x: x[1])
answer = 0
before_s, before_e = -1, -1
# print(target)
for s, e in target:
    if before_s <= s <= before_e or before_s <= e <= before_e:
        answer += 1
    else:
        before_s = s
        before_e = e
print(length - answer)

Submission status: Wrong Answer

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

N = int(input())
R = []

for i in range(N):
	x,l = map(int, input().split())
	R.append([max(x-l+1,0),x+l-1])
R.sort(key = lambda r : r[1])

ans = N
lr = -1
for i in range(N):
	if(lr >= R[i][0]):
		ans -=1
		continue
	else:
		lr = R[i][1]
print(ans)

Submission status: Wrong Answer

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

lis.sort(key=lambda x:x[0])
count = 0
tmp = - 10 ** 18
for i in lis:
    if tmp <= i[0]:
        count += 1
        tmp = i[1]

print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
lis=[]
for _  in range(n):
    x,l=map(int,input().split())
    #print(x,l)
    lis.append([x-l,x+l])

lis.sort(key=lambda x:x[0])
#print(lis)
count = 0
tmp = - 10 ** 18
for i in lis:
    #print(i,i[0],i[1])
    if tmp <= i[0]:
        count += 1
        tmp = i[1]

print(count)

Submission status: Wrong Answer

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

d.sort()

c = -float("inf")
ans = 0
for i in range(n):
    if c <= d[i][0]:
        c = d[i][1]
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
import copy
sys.setrecursionlimit(1000000000)
 
def solve(robots):
    total = len(robots)
    prev = None
    local_robots = copy.deepcopy(robots)
    for i, current in enumerate(robots):
        if count_collisions(current, local_robots) > 0:
            local_robots.remove(current)
            total -= 1
        else:
            prev = current
            
    return total
    
def count_collisions(current, robots):
    count = 0
    for robot in robots:
        if robot[0] < current[0] and robot[0] + robot[1] > current[0] - current[1]:
            count += 1
        if current[0] < robot[0] and current[0] + current[1] > robot[0] - robot[1]:
            count += 1
    print(current, count)
    return count

N, = map(int, input().split())
ROBOTS = [list(map(int, input().split())) for _ in range(N)]
ROBOTS = list(reversed(sorted(ROBOTS, key=lambda x: count_collisions(x, ROBOTS))))
print(solve(ROBOTS))

Submission status: Wrong Answer

Solution code:
import sys
import math
sys.setrecursionlimit(1000000000)

def solve(robots):
    total = len(robots)
    prev = None
    for i, current in enumerate(robots):
        if prev and prev[0] + prev[1] > current[0] - current[1]:
            total -= 1
            if (i + 1 < len(robots) and prev[0] + prev[1] > robots[i + 1][0] - robots[i + 1][1]):
                prev = current
        else:
            prev = current
            
    return total

N, = map(int, input().split())
ROBOTS = [list(map(int, input().split())) for _ in range(N)]
ROBOTS = sorted(ROBOTS, key=lambda x: x[0])
print(solve(ROBOTS))

Submission status: Wrong Answer

Solution code:
import sys
import math
sys.setrecursionlimit(1000000000)

def solve(robots):
    total = len(robots)
    prev = None
    for current in robots:
        if prev and prev[0] + prev[1] > current[0] - current[1]:
            total -= 1
        else:
            prev = current
            
    return total

N, = map(int, input().split())
ROBOTS = [list(map(int, input().split())) for _ in range(N)]
ROBOTS = sorted(ROBOTS, key=lambda x: x[0])
print(solve(ROBOTS))

Submission status: Wrong Answer

Solution code:
N = int(input())

p = []
for i in range(N):
  a,b = map(int,input().split())
  p.append([max(0,a - b),a + b])
  
q = sorted(p,key=lambda x:(x[0],x[1]))

c = 0
d = q[0][1] 
for j,k in q[1:]:
  if j < d:
    c += 1
  else:
    d = k  
  
print(N-c)

Submission status: Wrong Answer

Solution code:
N = int(input())

p = []
for i in range(N):
  a,b = map(int,input().split())
  p.append([max(0,a - b),a + b])
  
q = sorted(p,key=lambda x:x[0])  

cnt = 0
d = q[0][1]
for j,k in q[1:]:
  if j < d:
    cnt += 1
  else:
    d = k

print(N-cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
ST = []
for _ in range(N):
    x, l = map(int, input().split())
    ST.append((x - l, x + l))
ST.sort(key=lambda x: x[1])
# print(ST)
use_arms = [True] * N
for i in range(N-1):
    if not (use_arms[i] and use_arms[i+1]):
        continue

    if ST[i][1] > ST[i+1][0]:
        use_arms[i+1] = False

# print(use_arms)
print(sum(use_arms))

Submission status: Wrong Answer

Solution code:
N = int(input())
XL = []
for _ in range(N):
    XL.append(tuple(map(int, input().split())))
XL.sort()
# print(XL)
use_arms = [True] * N
for i in range(N-1):
    if not (use_arms[i] and use_arms[i+1]):
        continue

    if (XL[i][0] + XL[i][1]) > (XL[i+1][0] - XL[i+1][1]):
        if XL[i][0] + XL[i][1] < XL[i+1][0] + XL[i+1][1]:
            use_arms[i+1] = False
        else:
            use_arms[i] = False
    else:
        pass
# print(use_arms)
print(sum(use_arms))

Submission status: Wrong Answer

Solution code:
N=int(input())
cnt=1
R=[[0]*2 for _ in range(N)]
for i in range(N):
  x,l=map(int,input().split())
  R[i][0]=(x-l+1)
  R[i][1]=(x+l-1)
  
#print(R)
R.sort(key=lambda x: x[1])
#print(R)
for i in range(1,N):
  if R[i][0]>R[i-1][1]:
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
N=int(input())
cnt=1
R=[[0]*2 for _ in range(N)]
for i in range(N):
  x,l=map(int,input().split())
  R[i][0]=(x-l+1)
  R[i][1]=(x+l-1)
#print(R)
R.sort(key=lambda x: x[0])
#print(R)
for i in range(1,N):
  if R[i][0]>R[i-1][1]:
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
N=int(input())
cnt=1
R=[[0]*2 for _ in range(N)]
for i in range(N):
  x,l=map(int,input().split())
  R[i][0]=(x-l+1)
  R[i][1]=(x+l-1)
#print(R)
R.sort(key=lambda x: x[1])
#print(R)
for i in range(1,N):
  if R[i][0]>R[i-1][1]:
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
N=int(input())
cnt=1
R=[[0]*2 for _ in range(N)]
for i in range(N):
  x,l=map(int,input().split())
  R[i][0]=(x-l+1)
  R[i][1]=(x+l-1)
print(R)
R.sort(key=lambda x: x[1])
print(R)
for i in range(1,N):
  if R[i][0]>R[i-1][1]:
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
N=int(input())
cnt=1
R=[[0]*2 for _ in range(N)]
for i in range(N):
  x,l=map(int,input().split())
  R[i][0]=(x-l+1)
  R[i][1]=(x+l-1)
R.sort()
for i in range(1,N):
  if R[i][0]>R[i-1][1]:
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
m_list = []
for i in range(n):
  X, L = map(int, input().split())
  m_list.append([X-L,X+L])
 
m_list = sorted(m_list)
  
def MachineArrangementCheck():
  length = len(m_list)
  # 配列の上限エラー対策
  for i in range(length):
    if i != length - 1:      
      # m1の上限とm２の下限が接するかを確認
      if (m_list[i][1] - m_list[i+1][0]) < 0:
        del m_list[i+1]
        return False
  return True
 
while MachineArrangementCheck() == False:
  continue
  
print(len(m_list))

Submission status: Wrong Answer

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

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

Machine_list = sorted(Machine_list)
  
def MachineArrangementCheck():
  length = len(Machine_list)
  # 配列の上限エラー対策
  for i in range(length):
    if i != length - 1:
      M1 = Machine_list[i]
      M2 = Machine_list[i+1]

      # 上限下限を確認
      m1max = M1[0] + M1[1]
      m2min = M2[0] - M2[1]
      
      # m1の上限とm２の下限が接するかを確認
      if (m2min - m1max) < 0:
        del Machine_list[i+1]
        return False
  return True

while MachineArrangementCheck() == False:
  continue
  
print(len(Machine_list))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
count = 0
for i in range(n):
    x_l = list(map(int,input().split()))
    a.append(x_l)
    
for j in range(n-1):
    if (a[j][0] + a[j][1]) > (a[j+1][0] - a[j+1][1]):
        count += 1
        a[j+1][0] = a[j][0]
        a[j+1][1] = a[j][1]

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
count = 0
for i in range(n):
    x_l = list(map(int,input().split()))
    a.append(x_l)
    
for j in range(n-1):
    if (a[j][0] + a[j][1]) > (a[j+1][0] - a[j+1][1]):
        count += 1
        a[j+1][0] = a[j][0]
        a[j+1][1] = a[j][1]

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())

robot = []
for i in range(n):
    x, l = map(int, input().split())
    robot.append([x, l])
    
robot = sorted(robot, key=lambda x: x[0])

sei_deleterobot = 0
deleted = False
for i in range(1, n):
    if deleted:
        deleted = False
        continue

    if robot[i-1][0] + robot[i-1][1] > robot[i][0]:
        sei_deleterobot += 1
        deleted = True

fu_deleterobot = 0
deleted = False
for i in range(n-1, 0):
    if deleted:
        deleted = False
        continue

    if robot[i+1][0] - robot[i+1][1] < robot[i][0]:
        fu_deleterobot += 1
        deleted = True

if sei_deleterobot < fu_deleterobot:
    print(n - sei_deleterobot)
else:
    print(n - fu_deleterobot)

Submission status: Wrong Answer

Solution code:
n = int(input())

robot = []
for i in range(n):
    x, l = map(int, input().split())
    robot.append([x, l])
    
robot = sorted(robot, key=lambda x: x[0])

deleterobot = 0
deleted = False
irobot = 1
for i in range(1, n):
    if deleted:
        deleted = False
        continue

    if robot[i-1][0] + robot[i-1][1] > robot[i][0]:
        deleterobot += 1
        deleted = True

print(n - deleterobot)

Submission status: Wrong Answer

Solution code:
N = int(input())
robot = []
for _ in range(N):
  r = []
  x, l = map(int, input().split())
  a = x + l 
  b = x - l
  r += [a, b]
  robot.append(r)
Robot = sorted(robot)
 
robot_count = [Robot[0]]
for i in range(1, N):
  if Robot[i][1] > robot_count[-1][0]:
    robot_count.append(Robot[i])
 
print(len(robot_count))

Submission status: Wrong Answer

Solution code:
N = int(input())
robot = []
for _ in range(N):
  r = []
  x, l = map(int, input().split())
  a = x + l - 1
  b = x - l + 1
  r += [a, b]
  robot.append(r)
Robot = sorted(robot)
 
robot_count = [Robot[0]]
for i in range(1, N):
  if Robot[i][1] > robot_count[-1][0]:
    robot_count.append(Robot[i])
 
print(len(robot_count))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, X: "List[int]", L: "List[int]"):
    mixed_input = [[x,l] for x, l in zip(X, L)]
    sorted_input = sorted(mixed_input, key = lambda x: x[0])

    count = 0

    X = [i[0] for i in sorted_input]
    L = [i[1] for i in sorted_input]

    for i, (x, l) in enumerate(zip(X, L)):
        if (x - l + 1) <= (X[i-1] + L[i-1] - 1) and (i > 0):
            count += 1
    print(N - count)



# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = [int()] * (N)  # type: "List[int]"
    L = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        X[i] = int(next(tokens))
        L[i] = int(next(tokens))
    solve(N, X, L)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, X: "List[int]", L: "List[int]"):
    mixed_input = [[x,l] for x, l in zip(X, L)]
    sorted_input = sorted(mixed_input, key = lambda x: x[0])
    count = 0

    X = [i[0] for i in sorted_input]
    L = [i[1] for i in sorted_input]

    for i, (x, l) in enumerate(zip(X, L)):
        if (X[i-1] + L[i-1])-1 >= x - l + 1 and i > 0:
            count += 1
    print(len(X) - count)



# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = [int()] * (N)  # type: "List[int]"
    L = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        X[i] = int(next(tokens))
        L[i] = int(next(tokens))
    solve(N, X, L)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

N = int(input())
XL = []
for _ in range(N):
    tmp = [int(x) for x in input().split()]
    XL.append(tmp)
LR = []
for i in XL:
    LR.append([i[0] - i[1], i[0] + i[1]])
LR.sort()
ans = N
last = LR[0][1]
for i in range(1, N - 1):
    if last > LR[i][0]:
        if last > LR[i][1]:
            last = LR[i][1]
        ans -= 1
    else:
        last = LR[i][1]
print(ans)

Submission status: Wrong Answer

Solution code:
class Robot:
    def __init__(self, x, l):
        self.x = x
        self.l = l
    
    def __lt__(self, other):
        return self.x < other.x

n = int(input().rstrip())
robos = [None] * n

for i in range(n):
    line = input().rstrip().split(' ')
    robos[i] = Robot(int(line[0]), int(line[1]))

robos.sort()

i = 0
ans = 0
while i < n:
    s = robos[i].x
    r = robos[i].l
    i += 1
    while i < n and robos[i].x <= s + r:
        i += 1
    
    p = robos[i - 1].x
    while i < n and robos[i].x <= p + robos[i].l:
        i += 1
    
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
class Robot:
    def __init__(self, x, l):
        self.x = x
        self.l = l
    
    def __lt__(self, other):
        return self.x < other.x

n = int(input().rstrip())
robos = [None] * n

for i in range(n):
    line = input().rstrip().split(' ')
    robos[i] = Robot(int(line[0]), int(line[1]))

robos.sort()

i = 0
ans = 0
while i < n:
    s = robos[i].x
    i += 1
    while i < n and robos[i].x <= s + robos[i].l:
        i += 1
    
    p = robos[i - 1].x
    while i < n and robos[i].x <= p + robos[i].l:
        i += 1
    
    ans += 1

print(ans)

Submission status: Wrong Answer

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

x = []*n
y = []*2

for i in range(n):
  y.append(h[i][0]-h[i][1]) #腕が届く地点の最小値
  y.append(h[i][0]+h[i][1]) #腕が届く地点の最大値
  x.append(y) 				#xに保存
  y = []*2 					#yを初期化

x.sort(key = lambda x:x[1]) #腕が届く地点の最大値が小さい順にソート

for i in range(n-1):
  k = 0						#配列xのtale

  if x[k][1] > x[k+1][0]: 	#k番目の最大値よりもk+1の最小値の方が小さい時(つまり腕が重なる時)
    x.pop(k+1) 				#k+1番目を取り出す

  else:
    k += 1					#taleを一個後ろに下げる

print(len(x))				#要素数(残ったロボットの数)を出力

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+1,x+l-1])
xl.sort(key=lambda x: x[1])

arm = xl[0][1] 
cnt = 1
for i in range(1,n):
    x,l = xl[i][0],xl[i][1]

    if arm < xl[i][0]:
        arm = xl[i][1]
        cnt +=1
        
print(cnt)

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+1,x+l-1])
 
xl.sort(key=lambda x: x[1])
print(xl)
arm = xl[0][1] 
cnt = 1
for i in range(1,n):
    x,l = xl[i][0],xl[i][1]

    if arm < xl[i][0]:
        arm = xl[i][1]
        cnt +=1
        
print(cnt)

Submission status: Wrong Answer

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

rng.sort()
count = 1
border = rng[0][0]

for i in rng[1:]:
    if border <= i[1]:
        count += 1
        border = i[0]
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
scope = []
for _ in range(n):
    x, l = map(int, input().split())
    scope.append([x+l, x-l])
    
scope.sort()
ans = 1
border = scope[0][0]
for i, r in enumerate(scope[1:]):
    if border <= r[0]:
        ans += 1
        border = r[1]
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
right = []
scope = {}
for _ in range(n):
    x, l = map(int, input().split())
    right.append(x+l)
    scope[x+l] = [x-l, x+l]
    
right.sort()
ans = 1
border = right[0]
for i, r in enumerate(right):
    if border <= scope[r][0]:
        ans += 1
        border = scope[r][1]
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
right = []
scope = {}
for _ in range(n):
    x, l = map(int, input().split())
    right.append(x+l)
    scope[x+l] = [x-l, x+l]
    
right.sort()
ans = 0
border = 10**9 * (-1)
for i, r in enumerate(right):
    if border <= scope[r][0]:
        ans += 1
        border = scope[r][1]
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
right = []
scope = {}
for _ in range(n):
    x, l = map(int, input().split())
    right.append(x+l)
    scope[x+l] = [x-l, x+l]
    
right.sort()
ans = 1
border = right[0]
for i, r in enumerate(right[1:]):
    if border <= scope[r][0]:
        ans += 1
        border = scope[r][1]
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
ls = []
for i in range(n):
    x,l = map(int,input().split())
    ls.append([x-l,l+x])

ls = sorted(ls, key=lambda x: x[1])
ans = n
print(ls)

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

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = []
ans = 0

i = 0
while i < N:
    x, l = input().split()
    X.append([int(x), int(l)])

    # j=0
    # while j < len(X):
    #     if X[j][0] > int(x):
    #         X.insert(j, [int(x), int(l)])
    #         break
    #     elif j == len(X) -1:
    #         X.append([int(x), int(l)])
    #         break
    #     j+=1
    # if i == 0 : X.append([int(x), int(l)])
    i+=1

X.sort()
# print(X)
pre = X[0][0] + X[0][1]
i=1
while i < N:
    left = X[i][0] - X[i][1]
    right = X[i][0] + X[i][1]
    
    if left < pre:
        ans += 1
    else:
        pre = right
    
    i += 1
print(N - ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = []
ans = 0
pre = 0
i = 0
while i < N:
    x, l = input().split()
    X.append([int(x), int(l)])

    # j=0
    # while j < len(X):
    #     if X[j][0] > int(x):
    #         X.insert(j, [int(x), int(l)])
    #         break
    #     elif j == len(X) -1:
    #         X.append([int(x), int(l)])
    #         break
    #     j+=1
    # if i == 0 : X.append([int(x), int(l)])
    i+=1

X.sort()
# print(X)
i=0
while i < N:
    left = X[i][0] - X[i][1]
    right = X[i][0] + X[i][1]
    
    if left < pre and i != 0:
        ans += 1
    else:
        pre = right
    
    i += 1
print(N - ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = []
ans = 0
pre = 0
i = 0
while i < N:
    x, l = input().split()
    X.append([int(x), int(l)])

    # j=0
    # while j < len(X):
    #     if X[j][0] > int(x):
    #         X.insert(j, [int(x), int(l)])
    #         break
    #     elif j == len(X) -1:
    #         X.append([int(x), int(l)])
    #         break
    #     j+=1
    # if i == 0 : X.append([int(x), int(l)])
    i+=1

X.sort()

i=0
while i < N:
    left = X[i][0] - X[i][1]
    right = X[i][0] + X[i][1]
    
    if left < pre and i != 0:
        ans += 1
    pre = right
    i += 1
print(N - ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = []
ans = 0
pre = 0
i = 0
while i < N:
    x, l = input().split()
    X.append([int(x), int(l)])

    # j=0
    # while j < len(X):
    #     if X[j][0] > int(x):
    #         X.insert(j, [int(x), int(l)])
    #         break
    #     elif j == len(X) -1:
    #         X.append([int(x), int(l)])
    #         break
    #     j+=1
    # if i == 0 : X.append([int(x), int(l)])
    i+=1

X.sort()
print(X)
i=0
while i < N:
    left = X[i][0] - X[i][1]
    right = X[i][0] + X[i][1]
    
    if left < pre and i != 0:
        ans += 1
    pre = right
    i += 1
print(N - ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = []
ans = 0
pre = 0
i = 0
while i < N:
    x, l = input().split()
    j=0
    
    while j < len(X):
        if X[j][0] > int(x):
            X.insert(j, [int(x), int(l)])
            break
        elif j == len(X) -1:
            X.append([int(x), int(l)])
            break
        j+=1
    if i == 0 : X.append([int(x), int(l)])
    i+=1
i=0
while i < N:
    left = X[i][0] - X[i][1]
    right = X[i][0] + X[i][1]
    
    if left < pre and i != 0:
        ans += 1
    pre = right
    i += 1
print(N - ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
dic = {}
lim = -10*9
for _ in range(n):
  x,l = map(int,input().split())
  dic[l+x] = x
dic = sorted(dic.items())
a = 0
lim = -10*9
for i in dic:
  if lim>i[0]-2*(i[0]-i[1]):
    continue
  else:
    a += 1
    lim = i[0]
print(a)

Submission status: Wrong Answer

Solution code:
n = int(input())
dic = {}
lim = -10*9
for _ in range(n):
  x,l = map(int,input().split())
  dic[l+x] = x
dic = sorted(dic.items())
a = 0
lim = -10*9
for i in dic:
  if lim>i[1]:
    continue
  else:
    a += 1
    lim = i[0]
print(a)

Submission status: Wrong Answer

Solution code:
n = int(input())
dic = {}
lim = -10*9
for _ in range(n):
  x,l = map(int,input().split())
  dic[x] = l
dic = sorted(dic.items())
a = 0
lim = -10*9
for i in dic:
  if lim > i[0]-i[1]:
    continue
  else:
    a += 1
    lim = i[0]+i[1]
print(a)

Submission status: Wrong Answer

Solution code:
n = int(input())

arms = []
for i in range(n):
  x, l = [int(i) for i in input().split(' ')]
  arms.append({"st": x-l, "ed": x+l})

arms.sort(key=lambda x: x["ed"])
print(arms)

n_arm = 1
tot_end = arms[0]["ed"]

for i in range(1, n):
  if tot_end <= arms[i]["st"]:
    n_arm += 1
    tot_end = arms[i]["ed"]

print(n_arm)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
X = []
for i in range(N):
  X.append(list(map(int,input().split())))
  X[i].append(X[i][0] + X[i][1])

X = np.array(X)
X = X[X[:,1].argsort(),:]
X = X[X[:,2].argsort(),:]

D = []
j = 0
for i in range(1,N):
    if (X[j,2] -1 >= X[i,0] - X[i,1] +1):
      D.append(i)
      j -= 1
    j += 1

print(N - len(D))

Submission status: Wrong Answer

Solution code:
n = int(input())

machines = []
for i in range(n):
  x, l = map(int, input().split())
  machines.append([x+l, x-l])
machines.sort()

ans = 1
first = machines.pop(0)
stock_r = first[0]
for r,l in machines:
  if stock_r > l:
    break
  else:
    ans += 1
    stock_r = r

print(ans)