結果

問題 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,619 ms / 2,000 ms
コード長 1,170 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 34,452 KB
最終ジャッジ日時 2024-05-08 18:51:31
合計ジャッジ時間 53,374 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,880 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 30 ms
10,880 KB
testcase_03 AC 30 ms
10,880 KB
testcase_04 AC 30 ms
10,880 KB
testcase_05 AC 28 ms
10,752 KB
testcase_06 AC 29 ms
10,752 KB
testcase_07 AC 29 ms
10,880 KB
testcase_08 AC 29 ms
10,752 KB
testcase_09 AC 31 ms
10,752 KB
testcase_10 AC 30 ms
10,752 KB
testcase_11 AC 29 ms
10,752 KB
testcase_12 AC 30 ms
10,752 KB
testcase_13 AC 595 ms
19,224 KB
testcase_14 AC 1,456 ms
32,272 KB
testcase_15 AC 759 ms
21,908 KB
testcase_16 AC 749 ms
21,652 KB
testcase_17 AC 562 ms
18,836 KB
testcase_18 AC 1,048 ms
26,260 KB
testcase_19 AC 974 ms
24,976 KB
testcase_20 AC 1,187 ms
28,432 KB
testcase_21 AC 70 ms
11,520 KB
testcase_22 AC 1,097 ms
26,256 KB
testcase_23 AC 882 ms
23,696 KB
testcase_24 AC 195 ms
13,328 KB
testcase_25 AC 1,538 ms
33,300 KB
testcase_26 AC 1,597 ms
34,324 KB
testcase_27 AC 759 ms
22,032 KB
testcase_28 AC 1,605 ms
34,324 KB
testcase_29 AC 1,610 ms
34,324 KB
testcase_30 AC 1,591 ms
34,324 KB
testcase_31 AC 1,618 ms
34,452 KB
testcase_32 AC 1,601 ms
34,320 KB
testcase_33 AC 1,583 ms
34,328 KB
testcase_34 AC 1,606 ms
34,324 KB
testcase_35 AC 1,598 ms
34,452 KB
testcase_36 AC 1,583 ms
34,320 KB
testcase_37 AC 1,594 ms
34,448 KB
testcase_38 AC 1,612 ms
34,448 KB
testcase_39 AC 1,610 ms
34,320 KB
testcase_40 AC 1,619 ms
34,320 KB
testcase_41 AC 1,594 ms
34,324 KB
testcase_42 AC 1,593 ms
34,448 KB
testcase_43 AC 1,577 ms
24,896 KB
testcase_44 AC 1,568 ms
24,980 KB
testcase_45 AC 1,577 ms
24,988 KB
testcase_46 AC 1,523 ms
24,980 KB
testcase_47 AC 1,567 ms
24,984 KB
testcase_48 AC 1,609 ms
34,452 KB
testcase_49 AC 1,573 ms
34,324 KB
testcase_50 AC 29 ms
10,752 KB
testcase_51 AC 29 ms
10,752 KB
testcase_52 AC 29 ms
10,752 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