結果
| 問題 |
No.2330 Eat Slime
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 21:29:45 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,219 bytes |
| コンパイル時間 | 350 ms |
| コンパイル使用メモリ | 81,896 KB |
| 実行使用メモリ | 53,884 KB |
| 最終ジャッジ日時 | 2025-04-15 21:32:46 |
| 合計ジャッジ時間 | 7,504 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 TLE * 1 -- * 24 |
ソースコード
import bisect
def main():
import sys
input = sys.stdin.read
data = input().split()
idx = 0
N = int(data[idx])
idx += 1
M = int(data[idx])
idx += 1
X = int(data[idx])
idx += 1
C = list(map(int, data[idx:idx+N]))
idx += N
C = [0] + C # 1-based indexing
sum_ = [[0]*(N+2) for _ in range(6)] # sum_[c][a]
positions = [[] for _ in range(6)] # positions[c]
for _ in range(M):
A_j = int(data[idx])
idx += 1
B_j = int(data[idx])
idx += 1
Y_j = int(data[idx])
idx += 1
sum_[B_j][A_j] += Y_j
for i in range(1, N+1):
color = C[i]
positions[color].append(i)
max_total = 0
for K in range(0, N+1):
current = X * K
L = N - K
for color in range(1, 6):
lst = positions[color]
idx_pos = bisect.bisect_left(lst, K+1)
for pos in lst[idx_pos:]:
a = pos - K
if a > L:
continue
current += sum_[color][a]
if current > max_total:
max_total = current
print(max_total)
if __name__ == "__main__":
main()
lam6er