結果

問題 No.1536 仕切り直し
ユーザー SidewaysOwlSidewaysOwl
提出日時 2021-10-23 13:43:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,146 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 81,516 KB
実行使用メモリ 66,516 KB
最終ジャッジ日時 2023-10-25 09:41:44
合計ジャッジ時間 2,958 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,520 KB
testcase_01 AC 43 ms
55,520 KB
testcase_02 AC 43 ms
55,520 KB
testcase_03 WA -
testcase_04 AC 55 ms
64,092 KB
testcase_05 AC 61 ms
66,504 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 62 ms
66,516 KB
testcase_11 WA -
testcase_12 AC 60 ms
66,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
a = list(map(int,input().split()))
from collections import defaultdict
d_minus,d_plus = defaultdict(int),defaultdict(int)
if a[0] >= 0:turn = -1
else:turn = 1
idx = 0
lan = []
for i in range(n):
    if turn * a[i] >= 0:
        lan[len(lan)-1][0] += a[i]
    else:
        turn *= -1
#         if turn == 1:
#             d_plus[]
#         else:
        if len(lan) != 0:
            lan[len(lan)-1].append(i)
        lan.append([a[i],i])
lan[-1].append(n)
lan.sort(key = lambda x:x[0])
ans = []
for val,l,r in lan:
    if val < 0:
        m -= 2
        ans.append(l)
        ans.append(r)
        if r == n:
            m += 1
if m >=0:
    for i in range(m):
        ans.append(n)
    for idx in ans:
        print(idx)
else:
    not_ans = set()
    for val,l,r in lan:
        if val >= 0:
            if r != n : 
                not_ans.add(r)
                m += 1
            if l == 0:
                continue
            not_ans.add(l)
            m += 1
        if m >= 0:
            break
    if m == 1:
        ans.append(n)
    for idx in ans:
        if not idx in not_ans:
            print(idx)
0