結果

問題 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)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 683 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 50,944 KB
最終ジャッジ日時 2024-05-08 18:13:46
合計ジャッジ時間 63,453 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,624 KB
testcase_01 AC 34 ms
10,752 KB
testcase_02 AC 30 ms
10,624 KB
testcase_03 AC 31 ms
10,624 KB
testcase_04 AC 30 ms
10,624 KB
testcase_05 AC 29 ms
10,624 KB
testcase_06 AC 30 ms
10,624 KB
testcase_07 AC 29 ms
10,496 KB
testcase_08 AC 30 ms
10,752 KB
testcase_09 AC 30 ms
10,752 KB
testcase_10 AC 31 ms
10,624 KB
testcase_11 AC 29 ms
10,624 KB
testcase_12 AC 31 ms
10,624 KB
testcase_13 AC 722 ms
25,216 KB
testcase_14 AC 1,786 ms
47,232 KB
testcase_15 AC 943 ms
29,696 KB
testcase_16 AC 912 ms
29,184 KB
testcase_17 AC 693 ms
24,320 KB
testcase_18 AC 1,297 ms
36,992 KB
testcase_19 AC 1,176 ms
34,944 KB
testcase_20 AC 1,455 ms
40,576 KB
testcase_21 AC 78 ms
11,776 KB
testcase_22 AC 1,281 ms
36,736 KB
testcase_23 AC 1,059 ms
32,256 KB
testcase_24 AC 233 ms
14,976 KB
testcase_25 AC 1,871 ms
49,024 KB
testcase_26 AC 1,941 ms
50,688 KB
testcase_27 AC 932 ms
29,440 KB
testcase_28 AC 1,939 ms
50,688 KB
testcase_29 AC 1,953 ms
50,688 KB
testcase_30 AC 1,952 ms
50,816 KB
testcase_31 AC 1,960 ms
50,688 KB
testcase_32 AC 1,960 ms
50,816 KB
testcase_33 TLE -
testcase_34 AC 1,959 ms
50,944 KB
testcase_35 AC 1,960 ms
50,688 KB
testcase_36 AC 1,965 ms
50,688 KB
testcase_37 AC 1,938 ms
50,816 KB
testcase_38 AC 1,927 ms
50,688 KB
testcase_39 AC 1,949 ms
50,816 KB
testcase_40 AC 1,947 ms
50,816 KB
testcase_41 AC 1,953 ms
50,816 KB
testcase_42 AC 1,940 ms
50,688 KB
testcase_43 AC 1,893 ms
41,344 KB
testcase_44 AC 1,884 ms
41,344 KB
testcase_45 AC 1,859 ms
41,344 KB
testcase_46 AC 1,861 ms
41,344 KB
testcase_47 AC 1,852 ms
41,344 KB
testcase_48 AC 1,972 ms
50,688 KB
testcase_49 AC 1,927 ms
50,688 KB
testcase_50 AC 30 ms
10,624 KB
testcase_51 AC 30 ms
10,624 KB
testcase_52 AC 29 ms
10,624 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