結果
問題 | No.953 席 |
ユーザー | mkawa2 |
提出日時 | 2021-03-30 18:14:35 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,634 ms / 2,000 ms |
コード長 | 1,976 bytes |
コンパイル時間 | 152 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 138,496 KB |
最終ジャッジ日時 | 2024-11-30 17:16:42 |
合計ジャッジ時間 | 26,816 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
54,272 KB |
testcase_01 | AC | 48 ms
54,528 KB |
testcase_02 | AC | 739 ms
106,496 KB |
testcase_03 | AC | 610 ms
100,992 KB |
testcase_04 | AC | 730 ms
105,600 KB |
testcase_05 | AC | 500 ms
97,664 KB |
testcase_06 | AC | 750 ms
105,984 KB |
testcase_07 | AC | 907 ms
111,104 KB |
testcase_08 | AC | 1,634 ms
124,160 KB |
testcase_09 | AC | 860 ms
110,464 KB |
testcase_10 | AC | 437 ms
89,472 KB |
testcase_11 | AC | 1,106 ms
111,360 KB |
testcase_12 | AC | 1,206 ms
121,216 KB |
testcase_13 | AC | 1,390 ms
126,464 KB |
testcase_14 | AC | 1,066 ms
117,376 KB |
testcase_15 | AC | 1,037 ms
116,736 KB |
testcase_16 | AC | 1,051 ms
117,120 KB |
testcase_17 | AC | 1,148 ms
126,976 KB |
testcase_18 | AC | 1,121 ms
122,368 KB |
testcase_19 | AC | 1,497 ms
138,496 KB |
testcase_20 | AC | 1,161 ms
124,416 KB |
testcase_21 | AC | 837 ms
110,976 KB |
testcase_22 | AC | 1,139 ms
120,704 KB |
testcase_23 | AC | 877 ms
111,104 KB |
testcase_24 | AC | 896 ms
112,512 KB |
testcase_25 | AC | 1,428 ms
125,312 KB |
testcase_26 | AC | 377 ms
97,664 KB |
ソースコード
import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.buffer.readline()) def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def LI1(): return list(map(int1, sys.stdin.buffer.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def BI(): return sys.stdin.buffer.readline().rstrip() def SI(): return sys.stdin.buffer.readline().rstrip().decode() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 10**16 # md = 998244353 md = 10**9+7 from heapq import * from collections import deque n, k1, k2 = LI() seat = [-1]*(n+2) ent = (k1*2+k2)/3 vac = [] for j in range(1, n+1): heappush(vac, (0, abs(j-ent), j)) wait = deque() outin = [] q = II() ans = [-1]*q bb = [-1]*q for i in range(q): a, b = LI() bb[i] = b heappush(outin, (a, 1, i)) while outin: t, op, i = heappop(outin) if op: wait.append(i) else: j = i i = seat[j] seat[j] = -1 if seat[j-1] == -1 and seat[j+1] == -1: heappush(vac, (0, abs(j-ent), j)) else: heappush(vac, (1, abs(j-ent), j)) if j-1 >= 1 and seat[j-1] == -1 and seat[j-2] == -1: heappush(vac, (0, abs(j-1-ent), j-1)) if j+1 <= n and seat[j+1] == -1 and seat[j+2] == -1: heappush(vac, (0, abs(j+1-ent), j+1)) if outin and t == outin[0][0]: continue while wait and vac: side, d, j = heappop(vac) if seat[j] != -1: continue if side == 0 and (seat[j-1] != -1 or seat[j+1] != -1): heappush(vac, (1, d, j)) continue i = wait.popleft() seat[j] = i ans[i] = j heappush(outin, (t+bb[i], 0, j)) # print(t, seat, wait, outin) print(*ans, sep="\n")