結果

問題 No.1546 [Cherry 2nd Tune D] 思ったよりも易しくない
ユーザー 👑 rin204rin204
提出日時 2022-01-26 23:59:41
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 917 bytes
コンパイル時間 964 ms
コンパイル使用メモリ 85,284 KB
実行使用メモリ 109,828 KB
最終ジャッジ日時 2023-08-25 13:05:53
合計ジャッジ時間 84,111 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,308 KB
testcase_01 AC 68 ms
71,272 KB
testcase_02 AC 68 ms
71,364 KB
testcase_03 AC 69 ms
71,364 KB
testcase_04 AC 73 ms
71,380 KB
testcase_05 AC 68 ms
71,328 KB
testcase_06 AC 68 ms
71,180 KB
testcase_07 AC 68 ms
71,260 KB
testcase_08 AC 69 ms
71,384 KB
testcase_09 AC 69 ms
71,348 KB
testcase_10 AC 68 ms
71,332 KB
testcase_11 AC 67 ms
71,380 KB
testcase_12 AC 69 ms
71,432 KB
testcase_13 AC 951 ms
89,300 KB
testcase_14 TLE -
testcase_15 AC 1,221 ms
92,792 KB
testcase_16 AC 1,184 ms
92,216 KB
testcase_17 AC 896 ms
88,452 KB
testcase_18 AC 1,648 ms
98,476 KB
testcase_19 AC 1,527 ms
96,864 KB
testcase_20 AC 1,861 ms
101,104 KB
testcase_21 AC 172 ms
78,784 KB
testcase_22 AC 1,637 ms
98,432 KB
testcase_23 AC 1,387 ms
95,192 KB
testcase_24 AC 354 ms
81,144 KB
testcase_25 TLE -
testcase_26 TLE -
testcase_27 AC 1,206 ms
92,440 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
testcase_38 TLE -
testcase_39 TLE -
testcase_40 TLE -
testcase_41 TLE -
testcase_42 TLE -
testcase_43 TLE -
testcase_44 TLE -
testcase_45 TLE -
testcase_46 TLE -
testcase_47 TLE -
testcase_48 TLE -
testcase_49 TLE -
testcase_50 AC 69 ms
71,360 KB
testcase_51 AC 69 ms
71,336 KB
testcase_52 AC 68 ms
71,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353
"""
n = 6
A = [3, 3, 2, 1, 1, 1]
ans = 0
for i, a in enumerate(A):
    ans += a * (n - i) * (i + 1) * (i + 2) // 2
print(ans)
"""

n = int(input())
tv = [list(map(int, input().split())) for _ in range(n)]
n = sum(t for t, _ in tv) % MOD
inv2 = pow(2, MOD - 2, MOD)
inv6 = pow(6, MOD - 2, MOD)

def f(x):
    if x == -1:
        return 0
    ret = 0
    
    three = x * (x + 1) * inv2
    three = pow(three, 2, MOD)
    ret -= three
    ret %= MOD
    
    two = x * (x + 1) * (2 * x + 1) * inv6
    ret += (n - 3) * two
    ret %= MOD
    
    one = x * (x + 1) * inv2
    ret += (3 * n - 2) * one
    ret %= MOD
    
    ret += 2 * n * (x + 1)
    
    ret *= inv2
    return ret % MOD
    
    for i in range(x + 1):
        ret += (n - i) * (i + 1) * (i + 2) // 2
    return ret
    
    
ans = 0
l = 0
for t, v in tv:
    ans += v * (f(l + t - 1) - f(l - 1))
    ans %= MOD
    l += t
print(ans)
0