結果

問題 No.2229 Treasure Searching Rod (Hard)
ユーザー titia
提出日時 2023-03-06 03:19:22
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,001 ms / 2,000 ms
コード長 340 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-09-18 01:48:01
合計ジャッジ時間 19,702 ms
ジャッジサーバーID
(参考情報)
judge2 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W,K=map(int,input().split())
mod=998244353

ANS=0
for i in range(K):
    x,y,v=map(int,input().split())

    ANS+=x*v

    r=W-y
    if r<x-1:
        ANS+=(r*x-r*(r+1)//2)*v
    else:
        ANS+=((x-1)*x//2)*v
     
    l=y-1
    if l<x-1:
        ANS+=(l*x-l*(l+1)//2)*v
    else:
        ANS+=((x-1)*x//2)*v

    ANS%=mod

print(ANS)
0