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:
from operator import itemgetter
N=int(input())
arms=[]
for _ in range(N):
    x,l=map(int,input().split())
    a,b=x-l,x+l
    arms.append([a,b])

arms.sort(key=itemgetter(1))

cnt=1
tmp=arms[0][1]
for arm in arms:
    if arm[0]<tmp: continue
    cnt+=1

print(cnt)

Submission status: Wrong Answer

Solution code:
N=int(input())
arms=[]
for _ in range(N):
    x,l=map(int,input().split())
    a,b=x-l,x+l
    arms.append([a,b])

arms.sort()

i=0
cnt=0
while i<N-1:
    j=1
    while i+j<N and arms[i+j][0]<arms[i][1]:
        j+=1
    i+=j
    cnt+=j-1

print(N-cnt)

Submission status: Wrong Answer

Solution code:
import math
from typing import List, Any


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


def solve() -> Any:
    N = read_int()
    answer = 0
    XL = []
    for i in range(N):
        XL.append(read_ints())
    XL.sort(key=lambda xl: xl[0]-xl[1])
    XL2 = list(XL)
    XL2.sort(key=lambda xl: xl[0]+xl[1])
    dp = [0]*N
    j = -1
    for i, (x, l) in enumerate(XL):
        while XL2[j+1][0]+XL2[j+1][1] <= x-l:
            j += 1
        if j == -1:
            dp[i] = 1
        else:
            dp[i] = 1+dp[j]
    return dp[-1]


if __name__ == '__main__':
    print(solve())

Submission status: Wrong Answer

Solution code:
import math
from typing import List, Any


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


def solve() -> Any:
    N = read_int()
    answer = 0
    X, L = [], []
    for _ in range(N):
        x, l = read_ints()
        X.append(x)
        L.append(l)
    order = list(range(N))
    order.sort(key=lambda i:X[i])
    j = -1
    dp = [0]*N
    for i in order:
        while X[order[j+1]]+L[order[j+1]] <= X[i]-L[i]:
            j += 1
        if j == -1:
            dp[i] = 1
        else:
            dp[i] = 1+dp[order[j]]
    return dp[order[-1]]


if __name__ == '__main__':
    print(solve())

Submission status: Wrong Answer

Solution code:
N = int(input())
table = []
for i in range(N):
    X,L = map(int,input().split())
    table.append((X-L,X+L))
table = sorted(table, key=lambda x:x[1])

cur = 0
l_cur, r_cur = table[0]
ans = N
for i in range(1,N):
    l,r = table[i]
    if r_cur > l:
        ans -= 1
        if r_cur >= r:
            l_cur, r_cur = l, r
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
table = []
for i in range(N):
    X,L = map(int,input().split())
    table.append((X-L,X+L))
table.sort()

cur = 0
l_cur, r_cur = table[0]
ans = N
for i in range(1,N):
    l,r = table[i]
    if r_cur > l:
        ans -= 1
        if r_cur >= r:
            l_cur, r_cur = l, r
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input());a=0;X=-99*5
for x,y in sorted([[x+y,x-y]for x,y in [list(map(int,input().split()))for _ in "_"*n]]):X=max(X,x*(b:=X<=y));a+=b
print(a)

Submission status: Wrong Answer

Solution code:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

N=intput()
L=[]
for _ in range(N):
    x,l=mint() 
    L.append([x-l,1])
    L.append([x+l,0])
L.sort()
tmp = 0
ans = 0
for l in L:
    if tmp==1 and l[1]==0:
        ans+=1
    tmp=l[1]
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
XL=[list(map(int,input().split())) for i in range(N)]
XL.sort(key=lambda x:x[0])
inf=10**9+1
nin=-inf
ans=0
for i in range(N):
    X=XL[i][0]
    L=XL[i][1]
    if X-L<nin:
        ans+=1
    else:
        nin=X+L

print(N-ans)

Submission status: Wrong Answer

Solution code:
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop, heapify
import copy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    n = I()
    ranges = []
    for i in range(n):
        x, l = LI()
        ranges.append([x - l, x + l])
    ranges.sort(key=lambda x: x[0])
    ans = n
    for i in range(1, n):
        if ranges[i - 1][1] > ranges[i][0]:
            ans -= 1
            if ranges[i - 1][1] - ranges[i - 1][0] > ranges[i][1] - ranges[i][0]:
                ranges[i][1] = -INF
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop, heapify
import copy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    n = I()
    ranges = []
    for i in range(n):
        x, l = LI()
        ranges.append([x - l, x + l])
    ranges.sort(key=lambda x: x[0])
    ans = n
    for i in range(1, n):
        if ranges[i - 1][1] > ranges[i][0]:
            ans -= 1
            ranges[i][1] = -INF
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop, heapify
import copy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    n = I()
    ranges = []
    for i in range(n):
        x, l = LI()
        ranges.append([x - l + 1, x + l - 1])
    ranges.sort(key=lambda x: x[0])
    ans = n
    for i in range(1, n):
        if ranges[i - 1][1] >= ranges[i][0]:
            ans -= 1
            ranges[i][1] = -INF
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop, heapify
import copy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    n = I()
    ranges = []
    for i in range(n):
        x, l = LI()
        ranges.append((x - l + 1, x + l - 1))
    ranges.sort(key=lambda x: x[0])
    ans = n
    for i in range(1, n):
        if ranges[i - 1][1] >= ranges[i][0]:
            ans -= 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
se = [()] * N
for i in range(N):
	x, l = map(int, input().split())
	se[i] = (x-l, x+l)
se = sorted(se, key=lambda x: x[1])
ans = N
for i in range(1, N):
	if se[i-1][1] > se[i][0]:
		ans -= 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
pos_list = []
for _ in range(N):
    X, L = map(int, input().split())
    pos_list.append([X - L, X + L])
sorted_data = sorted(pos_list, key=lambda x: (x[0], -x[1]))
# print(pos_list)
ans = 0
current = -(10 ** 9)
for val in sorted_data:
    if current <= val[0]:
        ans += 1
        current = val[1]
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
pos_list = []
for _ in range(N):
    X, L = map(int, input().split())
    pos_list.append([X - L, X + L])
pos_list.sort()
# print(pos_list)
ans = 0
current = -(10 ** 9)
for val in pos_list:
    if current <= val[0]:
        ans += 1
        current = val[1]
print(ans)

Submission status: Wrong Answer

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

arms.sort()

ans = 1
left = arms[0][0] + arms[0][1]
for i in range(1, N):
  if left < arms[i][0] - arms[i][1]:
    ans += 1
    left = arms[i][0] + arms[i][1]

print(ans)

Submission status: Wrong Answer

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

arms.sort()

ans = 1
left = arms[0][0] + arms[0][1]
for i in range(1, N):
  if left <= arms[i][0] - arms[i][1]:
    ans += 1
    left = arms[i][0] + arms[i][1]

print(ans)

Submission status: Wrong Answer

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

arms.sort()

ans = N
i = 1
while True:
  flag = False
  left = arms[i-1][0] + arms[i-1][1]

  if i >= N - 2:
    break

  if left > arms[i][0] - arms[i][1] or arms[i][0] + arms[i][1] > arms[i+1][0] - arms[i+1][1]:
    flag = True
  
  if flag:
    i += 1
    ans -= 1
  else:
    left = arms[i][0] + arms[i][1]

  i += 1

  

print(ans)

Submission status: Wrong Answer

Solution code:
# キーエンス プログラミング コンテスト 2020: B – Robot Arms
N = int(input())
X, L = [], []
for _ in range(N):
    tmp = [int(i) for i in input().split()]
    X.append(tmp[0])
    L.append(tmp[1])

X_sorted = list(sorted(X))
L_sorted = []

for x in X_sorted:
    L_sorted.append(L[X.index(x)])

if len(X_sorted) == 1:
    print(1)
elif len(X_sorted) == 2:
    if X_sorted[0] + L_sorted[0] > X_sorted[1] - L_sorted[1]:
        del X_sorted[1]
        del L_sorted[1]
else:
    for i in range(1, len(X_sorted) - 1):

        if i > len(X_sorted) - 2:
            break

        if X_sorted[i -1] + L_sorted[i - 1] > X_sorted[i] - L_sorted[i] \
                or X_sorted[i] + L_sorted[i] > X_sorted[i + 1] - L_sorted[i + 1]:
            del X_sorted[i]
            del L_sorted[i]

print(len(X_sorted))

Submission status: Wrong Answer

Solution code:
N=int(input())
INF=10**20

X=[]
for i in range(N):
  x,l=map(int,input().split())
  X.append((x-l,x+l-1))
  
X = sorted(X)
rmax=-INF
res=[]
for i in range(N):
  cnt=0
  if rmax>=X[i][0]:
    cnt+=1
  if i<N-1 and X[i][1]>=X[i+1][0]:
    cnt+=1
  res.append(cnt)
  rmax = max(rmax,X[i][1])
  
dellist=[]
for i in range(len(res)):
  if res[i]==2:
    dellist.append(i)

for i in range(len(dellist)):
  del X[dellist[-i-1]]
  
rmax=-INF
res=[]
N=len(X)
for i in range(N):
  cnt=0
  if rmax>=X[i][0]:
    cnt+=1
  if i<N-1 and X[i][1]>=X[i+1][0]:
    cnt+=1
  res.append(cnt)
  rmax = max(rmax,X[i][1])
  
dellist=[]
flag=0
for i in range(len(res)-1):
  if flag==0 and res[i]==res[i+1]==1:
    dellist.append(i)
    flag=1
  if flag:
    flag=0

for i in range(len(dellist)):
  del X[dellist[-i-1]]
  
rmax=-INF
res=[]
N=len(X)
for i in range(N):
  cnt=0
  if rmax>=X[i][0]:
    cnt+=1
  if i<N-1 and X[i][1]>=X[i+1][0]:
    cnt+=1
  res.append(cnt)
  rmax = max(rmax,X[i][1])
  
dellist=[]
flag=0
for i in range(len(res)-1):
  if flag==0 and res[i]==res[i+1]==1:
    dellist.append(i)
    flag=1
  if flag:
    flag=0

for i in range(len(dellist)):
  del X[dellist[-i-1]]
  
print(len(X))

Submission status: Wrong Answer

Solution code:
N=int(input())
INF=10**20

X=[]
for i in range(N):
  x,l=map(int,input().split())
  X.append((x-l,x+l-1))
  
X = sorted(X)
rmax=-INF
res=[]
for i in range(N):
  cnt=0
  if rmax>=X[i][0]:
    cnt+=1
  if i<N-1 and X[i][1]>=X[i+1][0]:
    cnt+=1
  res.append(cnt)
  rmax = max(rmax,X[i][1])
  
dellist=[]
for i in range(len(res)):
  if res[i]==2:
    dellist.append(i)

for i in range(len(dellist)):
  del X[dellist[-i-1]]
  
rmax=-INF
res=[]
N=len(X)
for i in range(N):
  cnt=0
  if rmax>=X[i][0]:
    cnt+=1
  if i<N-1 and X[i][1]>=X[i+1][0]:
    cnt+=1
  res.append(cnt)
  rmax = max(rmax,X[i][1])
  
dellist=[]
flag=0
for i in range(len(res)-1):
  if flag==0 and res[i]==res[i+1]==1:
    dellist.append(i)
    flag=1
  if flag:
    flag=0

for i in range(len(dellist)):
  del X[dellist[-i-1]]
  
print(len(X))

Submission status: Wrong Answer

Solution code:
n = int(input())

robot_list = []

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

delete_robot = 0
robot_list.sort()
temp_robot = robot_list[0]

for i in range(n-1):
    if temp_robot[0] < robot_list[i+1][1]:
        delete_robot += 1
    else:
        temp_robot = robot_list[i+1]

print(n - delete_robot)

Submission status: Wrong Answer

Solution code:
N=int(input())
import copy
sw=False
ans=copy.deepcopy(N)
li=[]

for k in range(N):
    a,b=map(int,input().split())
    li.append([a,b])
li.sort()

dl=li[0][0]-li[0][1]+0.1
dr=li[0][0]+li[0][1]-0.1

for i in range(1,N):
    Dl=li[i][0]-li[i][1]+0.1
    Dr=li[i][0]+li[i][1]-0.1
    if dr>=Dl:
        ans-=1
    else:
        dl=copy.deepcopy(Dl)
        dr=copy.deepcopy(Dr)
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
import copy

ans=copy.deepcopy(N)
li=[]

for k in range(N):
    a,b=map(int,input().split())
    li.append([a,b])
li.sort()

dl=li[0][0]-li[0][1]+1
dr=li[0][0]+li[0][1]

for i in range(1,N):
    Dl=li[i][0]-li[i][1]+1
    Dr=li[i][0]+li[i][1]
    if dr>=Dl:
        ans-=1
    else:
        dl=Dl
        dr=Dr
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
import copy

ans=copy.deepcopy(N)
li=[]

for k in range(N):
    a,b=map(int,input().split())
    li.append([a,b])
li.sort()

dl=li[0][0]-li[0][1]+1
dr=li[0][0]+li[0][1]-1

for i in range(1,N):
    Dl=li[i][0]-li[i][1]+1
    Dr=li[i][0]+li[i][1]-1
    if dr>=Dl:
        ans-=1
    else:
        dl=Dl
        dr=Dr
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

robot_list = []

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

delete_robot = 0
robot_list.sort()
temp_robot = robot_list[0]

for i in range(n-1):
    if temp_robot[0]-1 > robot_list[i+1][1]+1:
        delete_robot += 1
    else:
        temp_robot = robot_list[i+1]

print(n - delete_robot)

Submission status: Wrong Answer

Solution code:
n = int(input())

robot_list = []

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

delete_robot = 0
robot_list.sort()
temp_robot = robot_list[0]

for i in range(n-1):
    if temp_robot[1]-1 >= robot_list[i+1][0]+1:
        delete_robot += 1
        if temp_robot[1] > robot_list[i+1][1]:
            temp_robot = robot_list[i+1]
    else:
        temp_robot = robot_list[i+1]

print(n - delete_robot)

Submission status: Wrong Answer

Solution code:
'''
Created on 2020/08/20

@author: harurun
'''
def main():
  import heapq
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  N=int(pin())
  a=[0]*N
  for i in range(N):
    x,l=map(int,pin().split())
    a[i]=[x,l]
  b=[0]*N
  for j in range(N):
    b[j]=[-a[j][0],a[j][1]]
  heapq.heapify(a)
  heapq.heapify(b)
  t=heapq.heappop(a)
  s=heapq.heappop(b)
#  perr(str(a))
#  perr(str(b))
  now1=t[0]+t[1]
  now2=-s[0]-s[1]
  ans1=N
  ans2=N
  for _ in [0]*(N-1):
    t=heapq.heappop(a)
    s=heapq.heappop(b)
    pm1=t[0]-t[1]
    pm2=-s[0]+s[1]
    if now1>pm1:
      ans1-=1
    else:
      now1=t[0]+t[1]
    if now2<pm2:
      ans2-=1
    else:
      now2=-1*s[0]-1*s[1]
  print(min(ans1,ans2))
  return

main()

Submission status: Wrong Answer

Solution code:
'''
Created on 2020/08/20

@author: harurun
'''
def main():
  import heapq
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  N=int(pin())
  a=[0]*N
  for i in range(N):
    x,l=map(int,pin().split())
    a[i]=[x,l]
  heapq.heapify(a)
  t=heapq.heappop(a)
  now=t[0]+t[1]
  ans=N
  for _ in [0]*(N-1):
    t=heapq.heappop(a)
    pm=t[0]-t[1]
    if now>pm:
      ans-=1
    else:
      now=t[0]+t[1]
  print(ans)
  return

main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
items = [list(map(int, input().split())) for i in range(N)]
items = sorted(items, key=lambda x:x[0]+x[1])
res = 0
bf =  -1
for x, l in items:
    if bf <= x:
        res += 1
        bf = x + l
print(res)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
items = [list(map(int, input().split())) for i in range(N)]
items = sorted(items, key=lambda x:x[0])
res = 0
bx = -10**9
bl = 0
for x, l in items:
    if bx+bl+l <= x:
        res += 1
        bx = x
        bl = l
    else:
        #print(x, l)
        pass
print(res)

Submission status: Wrong Answer

Solution code:
N=int(input())
xl=[list(map(int,input().split()))for _ in range(N)]
arms={}
for x,l in xl:
    arms[x-l]=0
    arms[x+l]=0
for x,l in xl:
    arms[x-l]+=1
    arms[x+l]-=1
point={}
for x,l in xl:
    point[x-l]=[]
    point[x+l]=[]
for x,l in xl:
    point[x-l].append(x+l)

ans=N
K=sorted(arms.keys())
now=0
count=[]
for k in K:
    now+=arms[k]
    for kk in point[k]:
        if kk in count:
            for i in range(count.count(kk)):
                count.remove(kk)
        else:
            count.append(kk)
    for i in range(count.count(k)):
        count.remove(k)
    if now>=2:
        ans-=now-1
        now=1
        C=sorted(count)[::-1]
        for c in C[:-1]:
            arms[c]+=1
            count.remove(c)

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
xl=[list(map(int,input().split()))for _ in range(N)]
arms={}
for x,l in xl:
    arms[x-l]=0
    arms[x+l]=0
for x,l in xl:
    arms[x-l]+=1
    arms[x+l]-=1
point={}
for x,l in xl:
    point[x-l]=[]
    point[x+l]=[]
for x,l in xl:
    point[x-l].append(x+l)

ans=N
K=sorted(arms.keys())
now=0
count=[]
for k in K:
    now+=arms[k]
    for kk in point[k]:
        if kk in count:
            count.remove(kk)
        else:
            count.append(kk)
    if now>=2:
        ans-=now-1
        now=1
        C=sorted(count)[::-1]
        for c in C[:-1]:
            arms[c]+=1
            count.remove(c)
    if k in count:
        count.remove(k)

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
xl=[list(map(int,input().split()))for _ in range(N)]
arms={}
for x,l in xl:
    arms[x-l]=0
    arms[x+l]=0
for x,l in xl:
    arms[x-l]+=1
    arms[x+l]-=1
point={}
for x,l in xl:
    point[x-l]=[]
    point[x+l]=[]
for x,l in xl:
    point[x-l].append(x+l)

ans=N
K=sorted(arms.keys())
now=0
count=[]
for k in K:
    now+=arms[k]
    for kk in point[k]:
        if kk in count:
            count.remove(kk)
        else:
            count.append(kk)
    if now>=2:
        ans-=now-1
        now=1
        C=sorted(count)[::-1]
        for c in C[:-1]:
            arms[c]+=1
            count.remove(c)

ans+=now==1
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
xl=[list(map(int,input().split()))for _ in range(N)]
arms={}
for x,l in xl:
    arms[x-l]=0
    arms[x+l]=0
for x,l in xl:
    arms[x-l]+=1
    arms[x+l]-=1
point={}
for x,l in xl:
    point[x-l]=[]
    point[x+l]=[]
for x,l in xl:
    point[x-l].append(x+l)

ans=N
K=sorted(arms.keys())
now=0
count=[]
for k in K:
    now+=arms[k]
    for kk in point[k]:
        if kk in count:
            count.remove(kk)
        else:
            count.append(kk)
    if now>=2:
        ans-=now-1
        now=1
        C=sorted(count)[::-1]
        for c in C[:-1]:
            arms[c]+=1
            count.remove(c)

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
xl=[list(map(int,input().split()))for _ in range(N)]
arm=[[0,0]for _ in range(2*N)]
i=0
for x,l in xl:
    arm[i][0]=x-l
    arm[i][1]+=1 
    arm[i+1][0]=x+l
    arm[i+1][1]-=1
    i+=2
arm.sort()

ans=N
S=0
count=0
for a,b in arm:
    S+=b
    if S>=2:
        count+=1
    if S==0:
        ans-=0--count//2
        count=0

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
xl=[list(map(int,input().split()))for _ in range(N)]
arm=[[0,0]for _ in range(2*N)]
i=0
for x,l in xl:
    arm[i][0]=x-l
    arm[i][1]+=1 
    arm[i+1][0]=x+l
    arm[i+1][1]-=1
    i+=2
arm.sort()

ans=N
S=0
for a,b in arm:
    S+=b
    if S>=2:
        ans-=S-1
        S=1
    if S<0:
        S=0

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
ls = [(0, 0)] * n
for i in range(n):
    x, ln = map(int, input().split())
    l = x - ln
    r = x + ln
    ls[i] = (l, x)
#print(ls)

ls.sort(key=lambda x: x[1])
#print(ls)
last = -float('inf')
count = 0
for i in ls:
    if last <= i[0]:
        count += 1
        last = i[1]
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
ls = [(0, 0)] * n
for i in range(n):
    x, ln = map(int, input().split())
    l = x - ln
    r = x + ln
    ls[i] = (l, x)
#print(ls)

ls.sort(key=lambda x: x[1])
#print(ls)
last = -float('inf')
count = 0
for i in ls:
    if last <= i[0]:
        count += 1
        last = i[1]
print(count)

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

ans = 0
cur = -100_000
for i in range(N):
    s, t = ST[i]
    if cur <= s:
        ans += 1
        cur = t
print(ans)

Submission status: Wrong Answer

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]


N = int(input())

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

XL.sort(key=lambda x: x[1])

ans = 0
cur = -100_000
for i in range(N):
    if cur <= XL[i][0]:
        ans += 1
        cur = XL[i][1]
print(ans)

Submission status: Wrong Answer

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]


N = int(input())

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

XL.sort(key=lambda x: x[1])

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

Submission status: Wrong Answer

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]


N = int(input())

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

XL.sort(key=lambda x: x[1])

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

Submission status: Wrong Answer

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]


N = int(input())

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

XL.sort()
ans = N
idx = 0
while idx < N-1:
    for i in range(idx+1, N):
        if XL[i][0] - XL[idx][0] < XL[idx][1] + XL[i][1]:
            ans -= 1
        else:
            idx = i
            break
    else:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
xl=[list(map(int,input().split()))for _ in range(N)]
xl.sort()
R=[0]*(N-1)
L=[0]*(N-1)
i=0
while i+1<N:
   R[i]=xl[i+1][0]-xl[i+1][1]
   i+=1
i=0
while  i<N-1:
    L[i]=sum(xl[i])
    i+=1

from bisect import*
count=[0]*N
i=0
while i<N:
    r=bisect_left(R,sum(xl[i]))-i
    l=i-bisect_right(L,xl[i][0]-xl[i][1])
    count[i]=r+l
    i+=1

count=[0]+count
ans=N
i=1
while i<N:
    count[i]=count[i]+count[i-1]
    if count[i]>0:
        if count[i+1]>=count[i]:
            count[i+1]=-1
            count[i]=0
            ans-=1
        else:
            count[i]=-1
            ans-=1
    i+=1

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

robo = sorted(robo, key=lambda x:x[1])

last = robo[0][1]
cnt = 1
for r in robo[1:]:
    if r[0] >= last:
        cnt += 1
        last = r[0]

print(cnt)

Submission status: Wrong Answer

Solution code:
# お尻から見ていってはやく終わるを数え上げれば良い
N = int(input())
data = []
for _ in range(N):
    X, L = map(int, input().split())
    data.append((X-L+1, X+L-1))
data = sorted(data, key=lambda x: x[1])

count = 1
j = N-1
for i in range(N-2, -1, -1):
    if data[i][1] <= data[j][0]:
        j = i
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
# お尻から見ていってはやく始まる方を数え上げれば良い
N = int(input())
data = []
for _ in range(N):
    X, L = map(int, input().split())
    data.append((X-L+1, X+L-1))
data.sort()

count = 1
j = N-1
for i in range(N-2, -1, -1):
    if data[i][1] <= data[j][0]:
        j = i
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=[[] for i in range(n)]
for i in range(n):
    x,l=map(int,input().split())
    A[i]=[x-l,x+l]
A=sorted(A, key=lambda x :x[1])
print(A)

ans=0
last=-float("INF")
for i in range(n):
    if last<=A[i][0]:
        ans+=1
        last=A[i][1]

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=[[] for i in range(n)]
for i in range(n):
    x,l=map(int,input().split())
    A[i]=[x-l,x+l]
A=sorted(A, key=lambda x :x[1])

last=0
ans=0
for i in range(n):
    if last<=A[i][0]:
        ans+=1
        last=A[i][1]

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
itv=[]
for i in range(n):
  x,l=map(int,input().split())
  itv+=[(x+l-1,x-l+1)]
itv=sorted(itv)
l=-10**18
cnt=0
for t,s in itv:
  if l<s:
    l=t
    cnt+=1
print(cnt)

Submission status: Wrong Answer

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

for i in range(N):
    x, l = map(int, input().split())
    R.append((x - l, x + l))

R.sort()

l = -(1 << 40)

cnt = 0
for r in R:
    if l <= r[0]:
        cnt += 1
        l = r[1]

print(cnt)