ABC005 C - おいしいたこ焼きの売り方
https://atcoder.jp/contests/abc005/tasks/abc005_3
提出
code: python
t = int(input())
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
can_buy_second = []
for i in a:
can_buy_second.append(i+t)
for cbs in can_buy_second:
customer = b.pop(0)
# 待たせてしまうことを考慮していない
if cbs < customer:
print('no')
exit()
if (len(b)):
print('no')
else:
print('yes')
解答
code: python
t = int(input())
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
tako_list = a
# 1, 3, 6, 10, 15
client_list = b
# 4, 8, 16
for client in client_list:
tmptako = tako for tako in tako_list if client-t <= tako <= client
if len(tmptako) != 0:
tako_list.remove(tmptako0)
else:
print("no")
exit()
print("yes")
テーマ
蟻本 2-2 Saruman's Army
メモ
/yu2ta7ka/AtCoder ABC 005 C - おいしいたこ焼きの売り方 (100点)
提出
AC/WA
https://atcoder.jp/contests/abc005/submissions/48966265
code: python
t = int(input())
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
# 0 1 2 3
# o o o
# x x x
# 0 1 2 3 4
# o o o
# x x x
# 0 1 2
# o o o
# x x
# x
# 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
# o o o o o
# x x x
# x を捌けるかという観点
row = max(a-1, b-1)
tako = []
client = 0 * row
for i in range(row):
if i+1 in a:
tako.append(True)
else:
tako.append(False)
for v in b:
clientv-1 += 1
for idx, v in enumerate(client):
tmptako = 0
if v != 0:
tmpi = []
# t 秒前までのインデックス
for i in range(idx, idx-t-1, -1):
if i < 0:
continue
else:
tmpi.append(i)
# 古い方から消費したい
tmpi.reverse()
for ti in tmpi:
if takoti:
tmptako += 1
takoti = False
if tmptako >= v:
break
if tmptako < v:
print("no")
exit()
print("yes")