結果

問題 No.1546 [Cherry 2nd Tune D] 思ったよりも易しくない
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2021-06-11 22:29:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 865 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 100,524 KB
最終ジャッジ日時 2023-08-21 13:08:26
合計ジャッジ時間 31,288 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,948 KB
testcase_01 AC 70 ms
71,112 KB
testcase_02 AC 68 ms
71,272 KB
testcase_03 AC 72 ms
71,172 KB
testcase_04 AC 70 ms
70,956 KB
testcase_05 AC 70 ms
71,212 KB
testcase_06 AC 69 ms
71,196 KB
testcase_07 AC 70 ms
71,384 KB
testcase_08 AC 70 ms
71,332 KB
testcase_09 AC 69 ms
71,100 KB
testcase_10 AC 70 ms
71,280 KB
testcase_11 AC 68 ms
71,328 KB
testcase_12 AC 71 ms
71,204 KB
testcase_13 AC 383 ms
82,892 KB
testcase_14 AC 764 ms
96,056 KB
testcase_15 AC 443 ms
85,200 KB
testcase_16 AC 432 ms
84,700 KB
testcase_17 AC 356 ms
82,240 KB
testcase_18 AC 583 ms
89,576 KB
testcase_19 AC 554 ms
87,856 KB
testcase_20 AC 649 ms
91,124 KB
testcase_21 AC 127 ms
77,612 KB
testcase_22 AC 581 ms
89,524 KB
testcase_23 AC 492 ms
86,576 KB
testcase_24 AC 184 ms
79,084 KB
testcase_25 AC 797 ms
96,264 KB
testcase_26 AC 827 ms
98,956 KB
testcase_27 AC 447 ms
85,504 KB
testcase_28 AC 827 ms
99,364 KB
testcase_29 AC 822 ms
99,192 KB
testcase_30 AC 831 ms
98,816 KB
testcase_31 AC 834 ms
99,096 KB
testcase_32 AC 833 ms
99,168 KB
testcase_33 AC 835 ms
99,072 KB
testcase_34 AC 833 ms
99,236 KB
testcase_35 AC 831 ms
99,232 KB
testcase_36 AC 836 ms
99,168 KB
testcase_37 AC 837 ms
99,220 KB
testcase_38 AC 839 ms
99,452 KB
testcase_39 AC 836 ms
99,164 KB
testcase_40 AC 837 ms
99,184 KB
testcase_41 AC 835 ms
99,208 KB
testcase_42 AC 832 ms
99,084 KB
testcase_43 AC 819 ms
100,448 KB
testcase_44 AC 812 ms
99,896 KB
testcase_45 AC 828 ms
100,524 KB
testcase_46 AC 789 ms
99,228 KB
testcase_47 AC 821 ms
100,132 KB
testcase_48 AC 865 ms
100,520 KB
testcase_49 AC 835 ms
99,072 KB
testcase_50 AC 72 ms
71,280 KB
testcase_51 AC 69 ms
71,116 KB
testcase_52 AC 70 ms
70,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
nod=[]
mod=998244353
sumt=0
for _ in range(n):
    t,v=map(int,input().split())
    sumt+=t
    sumt%=mod
    nod.append((t,v))
s=1
ans=0
rev2=pow(2,mod-2,mod)
def f1(x):
    return (x*(x+1)//2)%mod
def f2(x):
    return (x*(x+1)*(2*x+1)//6)%mod
def f3(x):
    return (f1(x)**2)%mod
n=sumt%mod
for t,v in nod:
    g=s+t-1
    subans=0
    subans+=n*(f2(g)-f2(s-1))
    subans+=-(f3(g)-f3(s-1))
    subans+=(n+1)*(f1(g)-f1(s-1))
    subans*=v*rev2
    ans+=subans
    ans%=mod
    s+=t


print(ans%mod)
0