結果
| 問題 | No.2330 Eat Slime |
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 15:45:29 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,144 bytes |
| コンパイル時間 | 382 ms |
| コンパイル使用メモリ | 82,284 KB |
| 実行使用メモリ | 121,336 KB |
| 最終ジャッジ日時 | 2025-06-12 15:45:37 |
| 合計ジャッジ時間 | 6,573 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 TLE * 1 -- * 24 |
ソースコード
import sys
from collections import defaultdict
def main():
N, M, X = map(int, sys.stdin.readline().split())
C = list(map(int, sys.stdin.readline().split()))
sum_y = defaultdict(dict)
for _ in range(M):
A, B, Y = map(int, sys.stdin.readline().split())
if B not in sum_y[A]:
sum_y[A][B] = 0
sum_y[A][B] += Y
# Build color_to_a
color_to_a = defaultdict(list)
for a in sum_y:
for c in sum_y[a]:
if sum_y[a][c] > 0:
color_to_a[c].append(a)
delta = [0] * (N + 2) # k can be 0 to N
for i in range(1, N + 1):
c = C[i - 1]
if c not in color_to_a:
continue
for a in color_to_a[c]:
if a > i:
continue
k = i - a
if k < 0:
continue
# 避免重复访问sum_y,直接计算
delta[k] += sum_y[a][c]
max_score = 0
for k in range(N + 1):
score = k * X + delta[k]
if score > max_score:
max_score = score
print(max_score)
if __name__ == '__main__':
main()
gew1fw