キーエンス2020 B - Robot Arms
https://atcoder.jp/contests/keyence2020/tasks/keyence2020_b
提出
TLE/WA
code: python
n = int(input())
x = []
l = []
for i in range(n):
X, L = int(i) for i in input().split()
x.append(X)
l.append(L)
arms = []
for i in range(n):
arms_l = [int(i) for i in range(xi, xi + li)] + [int(i) for i in range(xi - 1, xi - li, -1)]
arms.append(sorted(arms_l))
ans = n
for i in range(n-1):
if (armsi+10 < armsi-1):
ans -= 1
print(ans)
解答
code: python
n = int(input())
xl = list(map(int, input().split())) for _ in range(n)
arm = []
for x_l in xl:
arm.append((x_l0 - x_l1, x_l0 + x_l1))
arm = sorted(arm, key=lambda x: x1)
res = 0
tmp = -1e9
# 2 10000
# 4 3
# 9 3
# 100 5
# print(arm)
# (1, 7), (6, 12), (95, 105), (-9998, 10002)
for i in range(n):
if tmp <= armi0:
res += 1
tmp = armi1
print(res)
メモ
【AtCoder版!蟻本】キーエンスプロコン2020 B - Robot Arms【区間スケジューリング】
提出
code: python
n = int(input())
xl = list(map(int, input().split())) for _ in range(n)
arm = []
for x_l in xl:
arm.append((x_l0 - x_l1, x_l0 + x_l1))
arm = sorted(arm, key=lambda x: x1)
# 被ってる数を累積していきたい
for i, v in enumerate(arm):