0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

長テーブルのうなぎ屋 Python3編 解答 paizaラーニング

Posted at

問題

長テーブルのうなぎ屋 (paizaランク B 相当)
https://paiza.jp/learning/long-table

解答

unagiya.py
def is_ocupied_seats(num, place):
    for i in range(place, place+num):
        if seats[i%n] == True:
            return False
    return True

n, m = map(int, input().split())
seats = [False] * n

for _ in range(m):
    num, place = map(int, input().split())
    place -= 1
    if is_ocupied_seats(num, place):
        seats[place:place+num] = [True]*num
    # print(seats, is_ocupied_seats(num, place), place, num)
print(seats.count(True))
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?