結果
| 問題 |
No.2330 Eat Slime
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 18:21:21 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,316 bytes |
| コンパイル時間 | 220 ms |
| コンパイル使用メモリ | 82,688 KB |
| 実行使用メモリ | 54,272 KB |
| 最終ジャッジ日時 | 2025-06-12 18:21:52 |
| 合計ジャッジ時間 | 6,671 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / 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
from collections import defaultdict
groups = defaultdict(int)
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
groups[(A_j, B_j)] += Y_j
# Precompute positions for each color (1-based)
color_pos = defaultdict(list)
for i in range(N):
color = C[i]
color_pos[color].append(i+1) # 1-based
sum_Y = [0]*(N+1)
for (a, b), total in groups.items():
if a > N:
continue
if b not in color_pos:
continue
pos_list = color_pos[b]
# Find first index >= a
idx_p = bisect.bisect_left(pos_list, a)
for p in pos_list[idx_p:]:
K = p - a
if K <= N:
sum_Y[K] += total
max_score = 0
for K in range(N+1):
current = X * K + sum_Y[K]
if current > max_score:
max_score = current
print(max_score)
if __name__ == "__main__":
main()
gew1fw