結果

問題 No.1546 [Cherry 2nd Tune D] 思ったよりも易しくない
ユーザー mkawa2mkawa2
提出日時 2021-06-11 22:43:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 516 ms / 2,000 ms
コード長 1,170 bytes
コンパイル時間 936 ms
コンパイル使用メモリ 86,772 KB
実行使用メモリ 111,540 KB
最終ジャッジ日時 2023-08-21 13:30:43
合計ジャッジ時間 21,899 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,044 KB
testcase_01 AC 79 ms
71,260 KB
testcase_02 AC 78 ms
71,216 KB
testcase_03 AC 82 ms
71,024 KB
testcase_04 AC 81 ms
71,068 KB
testcase_05 AC 81 ms
70,916 KB
testcase_06 AC 81 ms
71,044 KB
testcase_07 AC 79 ms
71,248 KB
testcase_08 AC 78 ms
70,924 KB
testcase_09 AC 79 ms
71,208 KB
testcase_10 AC 78 ms
71,048 KB
testcase_11 AC 78 ms
71,176 KB
testcase_12 AC 79 ms
71,132 KB
testcase_13 AC 243 ms
84,612 KB
testcase_14 AC 463 ms
105,568 KB
testcase_15 AC 282 ms
87,212 KB
testcase_16 AC 278 ms
87,156 KB
testcase_17 AC 228 ms
83,104 KB
testcase_18 AC 353 ms
93,424 KB
testcase_19 AC 339 ms
90,664 KB
testcase_20 AC 395 ms
97,216 KB
testcase_21 AC 110 ms
77,444 KB
testcase_22 AC 352 ms
93,428 KB
testcase_23 AC 304 ms
88,820 KB
testcase_24 AC 137 ms
79,772 KB
testcase_25 AC 471 ms
105,860 KB
testcase_26 AC 491 ms
110,748 KB
testcase_27 AC 283 ms
87,464 KB
testcase_28 AC 499 ms
110,944 KB
testcase_29 AC 489 ms
110,768 KB
testcase_30 AC 498 ms
110,936 KB
testcase_31 AC 489 ms
110,740 KB
testcase_32 AC 493 ms
111,032 KB
testcase_33 AC 478 ms
110,728 KB
testcase_34 AC 481 ms
110,888 KB
testcase_35 AC 485 ms
110,920 KB
testcase_36 AC 491 ms
110,704 KB
testcase_37 AC 489 ms
110,540 KB
testcase_38 AC 489 ms
110,724 KB
testcase_39 AC 491 ms
110,904 KB
testcase_40 AC 486 ms
111,044 KB
testcase_41 AC 490 ms
110,832 KB
testcase_42 AC 497 ms
110,880 KB
testcase_43 AC 507 ms
110,848 KB
testcase_44 AC 505 ms
110,484 KB
testcase_45 AC 501 ms
110,396 KB
testcase_46 AC 478 ms
109,364 KB
testcase_47 AC 491 ms
110,548 KB
testcase_48 AC 516 ms
111,540 KB
testcase_49 AC 486 ms
110,624 KB
testcase_50 AC 79 ms
71,232 KB
testcase_51 AC 75 ms
71,188 KB
testcase_52 AC 75 ms
70,784 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