結果
| 問題 |
No.572 妖精の演奏
|
| コンテスト | |
| ユーザー |
ckawatak
|
| 提出日時 | 2019-03-09 17:20:00 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,101 bytes |
| コンパイル時間 | 168 ms |
| コンパイル使用メモリ | 82,244 KB |
| 実行使用メモリ | 68,064 KB |
| 最終ジャッジ日時 | 2024-06-23 15:14:20 |
| 合計ジャッジ時間 | 2,217 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 19 |
ソースコード
from collections import deque
N = int(input())
M = int(input())
S = []
for i in range(M):
scores = list(map(int, input().split(' ')))
que = deque()
for score_index in sorted([(score,i) for i,score in enumerate(scores)]):
que.append(score_index)
S.append(que)
U = []
for i in range(M):
U.append(deque())
def total(start, number):
visited = [False for _ in range(M)]
total = 0
n = 0
i = start
while n < number:
score,next = S[i].pop()
if visited[next]:
U[i].append((score,next))
continue
visited[next] = True
U[i].append((score,next))
total = total + score
i = next
n = n + 1
for j in range(M):
for _ in range(len(U[j])):
S[j].append(U[j].pop())
return total,i
if N < M:
print(0)
exit(0)
division = N // M
residual = N % M
answer = 0
for i in range(M):
total1,start = total(i,M)
total2,last = total(start,residual-1)
answer = max(answer, total1 * division + total2)
print(answer)
ckawatak