提出 #76931115
ソースコード 拡げる
N = int(input())
a_list = list(map(int, input().split()))
last_n = 0
last_d = 0
from collections import deque
astack = []
for n in range(N):
a = a_list[n]
if last_n == a:
last_d += 1
if last_d == a:
while astack and astack[-1][0] == a:
astack.pop()
print(len(astack))
if astack:
last_n = astack[-1][0]
last_d = astack[-1][1]
else:
last_n = 0
last_d = 0
# print(astack)
continue
else:
astack.append((a, last_d))
print(len(astack))
# print(astack)
else:
last_n = a
last_d = 1
astack.append((a, last_d))
print(len(astack))
# print(astack)
# print(len(astack))
提出情報
| 提出日時 | |
|---|---|
| 問題 | G - Strange Balls |
| ユーザ | kurome_rome |
| 言語 | Python (PyPy 3.11-v7.3.20) |
| 得点 | 400 |
| コード長 | 872 Byte |
| 結果 | AC |
| 実行時間 | 257 ms |
| メモリ | 139700 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 400 / 400 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | example_00.txt, example_01.txt |
| All | example_00.txt, example_01.txt, test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| example_00.txt | AC | 72 ms | 93336 KiB |
| example_01.txt | AC | 72 ms | 93628 KiB |
| test_00.txt | AC | 245 ms | 139572 KiB |
| test_01.txt | AC | 241 ms | 139592 KiB |
| test_02.txt | AC | 71 ms | 93500 KiB |
| test_03.txt | AC | 247 ms | 136496 KiB |
| test_04.txt | AC | 240 ms | 136392 KiB |
| test_05.txt | AC | 241 ms | 136376 KiB |
| test_06.txt | AC | 257 ms | 136504 KiB |
| test_07.txt | AC | 250 ms | 136620 KiB |
| test_08.txt | AC | 250 ms | 137816 KiB |
| test_09.txt | AC | 250 ms | 137860 KiB |
| test_10.txt | AC | 257 ms | 137492 KiB |
| test_11.txt | AC | 249 ms | 137808 KiB |
| test_12.txt | AC | 255 ms | 137624 KiB |
| test_13.txt | AC | 239 ms | 137728 KiB |
| test_14.txt | AC | 234 ms | 137544 KiB |
| test_15.txt | AC | 232 ms | 137688 KiB |
| test_16.txt | AC | 240 ms | 137568 KiB |
| test_17.txt | AC | 228 ms | 137652 KiB |
| test_18.txt | AC | 241 ms | 138636 KiB |
| test_19.txt | AC | 252 ms | 139700 KiB |