結果

問題 No.1546 [Cherry 2nd Tune D] 思ったよりも易しくない
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2021-06-11 22:29:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 964 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 342 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 99,388 KB
最終ジャッジ日時 2024-05-08 18:27:01
合計ジャッジ時間 33,268 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
51,712 KB
testcase_01 AC 42 ms
52,096 KB
testcase_02 AC 42 ms
51,968 KB
testcase_03 AC 43 ms
52,480 KB
testcase_04 AC 44 ms
52,480 KB
testcase_05 AC 42 ms
51,840 KB
testcase_06 AC 42 ms
51,968 KB
testcase_07 AC 43 ms
51,968 KB
testcase_08 AC 44 ms
52,480 KB
testcase_09 AC 44 ms
52,096 KB
testcase_10 AC 43 ms
52,608 KB
testcase_11 AC 42 ms
51,968 KB
testcase_12 AC 44 ms
52,736 KB
testcase_13 AC 379 ms
82,088 KB
testcase_14 AC 822 ms
95,052 KB
testcase_15 AC 470 ms
83,888 KB
testcase_16 AC 459 ms
83,792 KB
testcase_17 AC 362 ms
81,964 KB
testcase_18 AC 611 ms
88,616 KB
testcase_19 AC 573 ms
86,952 KB
testcase_20 AC 684 ms
90,544 KB
testcase_21 AC 117 ms
76,800 KB
testcase_22 AC 609 ms
88,624 KB
testcase_23 AC 522 ms
85,552 KB
testcase_24 AC 180 ms
78,592 KB
testcase_25 AC 870 ms
95,440 KB
testcase_26 AC 892 ms
98,260 KB
testcase_27 AC 482 ms
83,756 KB
testcase_28 AC 895 ms
98,260 KB
testcase_29 AC 894 ms
98,520 KB
testcase_30 AC 893 ms
98,136 KB
testcase_31 AC 891 ms
98,260 KB
testcase_32 AC 893 ms
98,512 KB
testcase_33 AC 891 ms
98,260 KB
testcase_34 AC 892 ms
98,128 KB
testcase_35 AC 899 ms
98,260 KB
testcase_36 AC 895 ms
98,256 KB
testcase_37 AC 894 ms
98,252 KB
testcase_38 AC 897 ms
98,388 KB
testcase_39 AC 897 ms
98,264 KB
testcase_40 AC 898 ms
98,384 KB
testcase_41 AC 964 ms
98,516 KB
testcase_42 AC 892 ms
98,264 KB
testcase_43 AC 880 ms
98,848 KB
testcase_44 AC 864 ms
98,524 KB
testcase_45 AC 882 ms
99,220 KB
testcase_46 AC 844 ms
99,048 KB
testcase_47 AC 879 ms
99,388 KB
testcase_48 AC 929 ms
99,244 KB
testcase_49 AC 891 ms
98,384 KB
testcase_50 AC 42 ms
51,712 KB
testcase_51 AC 43 ms
51,840 KB
testcase_52 AC 44 ms
52,096 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