結果
| 問題 | 
                            No.2330 Eat Slime
                             | 
                    
| コンテスト | |
| ユーザー | 
                             lam6er
                         | 
                    
| 提出日時 | 2025-04-16 15:30:58 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,239 bytes | 
| コンパイル時間 | 515 ms | 
| コンパイル使用メモリ | 81,768 KB | 
| 実行使用メモリ | 53,632 KB | 
| 最終ジャッジ日時 | 2025-04-16 15:35:09 | 
| 合計ジャッジ時間 | 6,891 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 5 TLE * 1 -- * 24 | 
ソースコード
import bisect
from collections import defaultdict
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
    
    color_positions = defaultdict(list)
    for pos in range(N):
        color = C[pos]
        color_positions[color].append(pos + 1)  # positions are 1-based
    
    sum_Yj = [0] * (N + 1)  # sum_Yj[K] for K from 0 to N
    
    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
        
        pos_list = color_positions.get(B_j, [])
        if not pos_list:
            continue
        
        # Find the first position >= A_j
        idx_pos = bisect.bisect_left(pos_list, A_j)
        for pos in pos_list[idx_pos:]:
            K = pos - A_j
            if K <= N:
                sum_Yj[K] += Y_j
    
    max_score = 0
    for K in range(N + 1):
        current = K * X + sum_Yj[K]
        if current > max_score:
            max_score = current
    print(max_score)
if __name__ == '__main__':
    main()
            
            
            
        
            
lam6er