結果

問題 No.1546 [Cherry 2nd Tune D] 思ったよりも易しくない
ユーザー tktk_snsntktk_snsn
提出日時 2021-06-11 22:19:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,595 ms / 2,000 ms
コード長 683 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 10,936 KB
実行使用メモリ 48,412 KB
最終ジャッジ日時 2023-08-21 12:55:46
合計ジャッジ時間 51,416 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,872 KB
testcase_01 AC 16 ms
7,800 KB
testcase_02 AC 15 ms
7,848 KB
testcase_03 AC 15 ms
7,932 KB
testcase_04 AC 16 ms
7,800 KB
testcase_05 AC 15 ms
7,864 KB
testcase_06 AC 15 ms
7,844 KB
testcase_07 AC 15 ms
7,804 KB
testcase_08 AC 16 ms
7,760 KB
testcase_09 AC 15 ms
7,760 KB
testcase_10 AC 15 ms
7,832 KB
testcase_11 AC 15 ms
7,888 KB
testcase_12 AC 16 ms
7,812 KB
testcase_13 AC 566 ms
22,620 KB
testcase_14 AC 1,429 ms
44,880 KB
testcase_15 AC 745 ms
27,276 KB
testcase_16 AC 732 ms
26,776 KB
testcase_17 AC 529 ms
21,968 KB
testcase_18 AC 1,019 ms
34,568 KB
testcase_19 AC 932 ms
32,416 KB
testcase_20 AC 1,151 ms
38,016 KB
testcase_21 AC 55 ms
9,332 KB
testcase_22 AC 1,007 ms
34,372 KB
testcase_23 AC 843 ms
29,848 KB
testcase_24 AC 181 ms
12,568 KB
testcase_25 AC 1,490 ms
46,556 KB
testcase_26 AC 1,561 ms
48,272 KB
testcase_27 AC 739 ms
27,052 KB
testcase_28 AC 1,555 ms
48,356 KB
testcase_29 AC 1,557 ms
48,412 KB
testcase_30 AC 1,558 ms
48,408 KB
testcase_31 AC 1,595 ms
48,264 KB
testcase_32 AC 1,557 ms
48,356 KB
testcase_33 AC 1,535 ms
48,300 KB
testcase_34 AC 1,543 ms
48,348 KB
testcase_35 AC 1,562 ms
48,356 KB
testcase_36 AC 1,545 ms
48,268 KB
testcase_37 AC 1,551 ms
48,352 KB
testcase_38 AC 1,561 ms
48,244 KB
testcase_39 AC 1,548 ms
48,392 KB
testcase_40 AC 1,561 ms
48,352 KB
testcase_41 AC 1,538 ms
48,260 KB
testcase_42 AC 1,556 ms
48,244 KB
testcase_43 AC 1,510 ms
38,928 KB
testcase_44 AC 1,495 ms
38,820 KB
testcase_45 AC 1,506 ms
38,892 KB
testcase_46 AC 1,512 ms
38,988 KB
testcase_47 AC 1,514 ms
38,864 KB
testcase_48 AC 1,545 ms
48,312 KB
testcase_49 AC 1,548 ms
48,344 KB
testcase_50 AC 15 ms
7,988 KB
testcase_51 AC 15 ms
7,820 KB
testcase_52 AC 15 ms
7,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

mod = 998244353
div2 = pow(2, mod-2, mod)
div4 = pow(4, mod-2, mod)
div6 = pow(6, mod-2, mod)

N = int(input())
TV = []
total = 0
for _ in range(N):
    t, v = map(int, input().split())
    t %= mod
    total += t
    total %= mod
    TV.append((t, v))


def F(n):
    x = (total + 1) * n * (n + 1) % mod
    y = total * n * (n + 1) * (2 * n + 1) % mod
    z = n * n * (n + 1) * (n + 1) % mod
    return (x * div2 % mod + y * div6 % mod - z * div4 % mod) * div2 % mod


ans = 0
cnt = 0
for t, v in TV:
    x = F(cnt + t) - F(cnt)
    ans += v * x % mod
    ans %= mod
    cnt += t
    cnt %= mod
print(ans)
0