結果

問題 No.1546 [Cherry 2nd Tune D] 思ったよりも易しくない
ユーザー mkawa2mkawa2
提出日時 2021-06-11 22:43:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,307 ms / 2,000 ms
コード長 1,170 bytes
コンパイル時間 542 ms
コンパイル使用メモリ 10,876 KB
実行使用メモリ 32,028 KB
最終ジャッジ日時 2023-08-21 13:30:01
合計ジャッジ時間 44,044 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,028 KB
testcase_01 AC 16 ms
8,012 KB
testcase_02 AC 15 ms
8,068 KB
testcase_03 AC 15 ms
8,080 KB
testcase_04 AC 15 ms
8,176 KB
testcase_05 AC 15 ms
8,180 KB
testcase_06 AC 14 ms
8,000 KB
testcase_07 AC 15 ms
8,124 KB
testcase_08 AC 15 ms
8,204 KB
testcase_09 AC 15 ms
8,088 KB
testcase_10 AC 16 ms
8,004 KB
testcase_11 AC 15 ms
8,168 KB
testcase_12 AC 16 ms
7,996 KB
testcase_13 AC 476 ms
16,744 KB
testcase_14 AC 1,181 ms
29,940 KB
testcase_15 AC 615 ms
19,460 KB
testcase_16 AC 601 ms
19,288 KB
testcase_17 AC 449 ms
16,472 KB
testcase_18 AC 858 ms
23,736 KB
testcase_19 AC 802 ms
22,616 KB
testcase_20 AC 950 ms
25,880 KB
testcase_21 AC 48 ms
8,792 KB
testcase_22 AC 843 ms
23,760 KB
testcase_23 AC 705 ms
21,004 KB
testcase_24 AC 152 ms
10,856 KB
testcase_25 AC 1,234 ms
30,900 KB
testcase_26 AC 1,299 ms
31,932 KB
testcase_27 AC 609 ms
19,376 KB
testcase_28 AC 1,291 ms
31,836 KB
testcase_29 AC 1,293 ms
31,844 KB
testcase_30 AC 1,299 ms
31,896 KB
testcase_31 AC 1,284 ms
32,028 KB
testcase_32 AC 1,281 ms
31,848 KB
testcase_33 AC 1,281 ms
31,836 KB
testcase_34 AC 1,286 ms
31,968 KB
testcase_35 AC 1,307 ms
31,836 KB
testcase_36 AC 1,302 ms
31,844 KB
testcase_37 AC 1,285 ms
32,012 KB
testcase_38 AC 1,303 ms
31,832 KB
testcase_39 AC 1,297 ms
31,920 KB
testcase_40 AC 1,299 ms
31,972 KB
testcase_41 AC 1,295 ms
31,848 KB
testcase_42 AC 1,294 ms
31,984 KB
testcase_43 AC 1,269 ms
22,564 KB
testcase_44 AC 1,267 ms
22,564 KB
testcase_45 AC 1,264 ms
22,428 KB
testcase_46 AC 1,247 ms
22,472 KB
testcase_47 AC 1,268 ms
22,460 KB
testcase_48 AC 1,286 ms
31,836 KB
testcase_49 AC 1,287 ms
31,972 KB
testcase_50 AC 15 ms
8,032 KB
testcase_51 AC 15 ms
8,128 KB
testcase_52 AC 16 ms
8,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
md = 998244353
# md = 10**9+7

inv = pow(24, md-2, md)

def coef(s, t):
    res = (s-t-1)*(3*(pow(s, 3, md)+pow(s, 2, md)*(t+3)+s*(pow(t, 2, md)+4*t+2)+t*(pow(t, 2, md)+5*t+6))-4*tn*(
            pow(s, 2, md)+s*(t+4)+pow(t, 2, md)+5*t+6))*inv
    return res%md

n = II()
tt, vv = [], []
for _ in range(n):
    t, v = LI()
    tt.append(t%md)
    vv.append(v)

l = r = 0
tn = sum(tt)%md
ans = 0
for t, v in zip(tt, vv):
    r = l+t-1
    ans += coef(l, r)*v
    ans %= md
    l = r+1

print(ans)
0