Skip to content

Instantly share code, notes, and snippets.

@ria3100
Last active October 2, 2017 21:43
Show Gist options
  • Save ria3100/de941b607fe4e59c3eac to your computer and use it in GitHub Desktop.
Save ria3100/de941b607fe4e59c3eac to your computer and use it in GitHub Desktop.
Paiza:長テーブルのうなぎ屋 (paizaランク B 相当)
# coding: utf-8
# Paiza Lerning 長テーブルのうなぎ屋 (paizaランク B 相当)
# https://paiza.jp/learning/long-table
n, m = map(int, input().split())
seat = 0
for i in range(m):
a, b = map(int, input().split())
guest = ['0']*(b-1) + ['1']*a + ['0']*(n-a-b+1)
guest = guest[n:] + guest[n*-1:n]
guest = int('0b' + ''.join(guest), 2)
if int(bin(seat & guest), 2) == 0:
seat = int(bin(seat | guest), 2)
print(bin(seat).count('1'))
@ria3100
Copy link
Author

ria3100 commented Dec 17, 2015

    guest = ['0']*(b-1) + ['1']*a + ['0']*(n-a-b+1)
    guest = guest[n:] + guest[n*-1:n]
    guest = int('0b' + ''.join(guest), 2)

この辺りもうちょっとスマートにならないかなぁ・・・

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment