結果

問題 No.3588 Already Ready
コンテスト
ユーザー ゼット
提出日時 2026-07-10 23:13:11
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 723 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,073 ms
コンパイル使用メモリ 95,816 KB
実行使用メモリ 117,760 KB
最終ジャッジ日時 2026-07-10 23:13:26
合計ジャッジ時間 8,468 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 68 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N,K=map(int,input().split())
M=int(input())
A=list(map(int,input().split()))
if A[M-1]<K+2:
  print(-1)
  exit()
for i in range(N):
  A[i]-=1
A[M-1]-=1
if sum(A)%(N+1)!=0:
  print(-1)
  exit()
p=sum(A)//(N+1)
if min(A)<p:
  print(-1)
  exit()
result=[-1]*(p+1)
root=[i for i in range(p+1)]
for i in range(N-1,-1,-1):
  x=A[i]
  win=x-p
  if x<=K+1:
    r=p
  else:
    c=K+1-2*win
    r=c+win
    if r>p:
      r=p
  now=r
  for _ in range(win):
    h=[]
    while True:
      h.append(now)
      if root[now]==now:
        break
      now=root[now]
    if now==0:
      print(-1)
      exit()
    result[now]=i+1
    for pos in h:
      root[pos]=now-1
result=result[1:]
result.append(M)
print(len(result))
print(*result)
0