結果
問題 | No.1546 [Cherry 2nd Tune D] 思ったよりも易しくない |
ユーザー | 👑 rin204 |
提出日時 | 2022-01-26 23:58:46 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 925 bytes |
コンパイル時間 | 953 ms |
コンパイル使用メモリ | 87,064 KB |
実行使用メモリ | 91,124 KB |
最終ジャッジ日時 | 2023-08-25 13:01:44 |
合計ジャッジ時間 | 14,350 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 59 ms
71,384 KB |
testcase_01 | AC | 57 ms
71,264 KB |
testcase_02 | AC | 57 ms
71,404 KB |
testcase_03 | AC | 60 ms
71,252 KB |
testcase_04 | AC | 59 ms
71,456 KB |
testcase_05 | AC | 61 ms
71,448 KB |
testcase_06 | AC | 60 ms
71,376 KB |
testcase_07 | AC | 58 ms
71,528 KB |
testcase_08 | AC | 59 ms
71,316 KB |
testcase_09 | AC | 59 ms
71,348 KB |
testcase_10 | AC | 58 ms
71,508 KB |
testcase_11 | AC | 58 ms
71,380 KB |
testcase_12 | AC | 61 ms
71,252 KB |
testcase_13 | AC | 1,508 ms
91,124 KB |
testcase_14 | TLE | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
testcase_50 | -- | - |
testcase_51 | -- | - |
testcase_52 | -- | - |
ソースコード
MOD = 998244353 """ n = 6 A = [3, 3, 2, 1, 1, 1] ans = 0 for i, a in enumerate(A): ans += a * (n - i) * (i + 1) * (i + 2) // 2 print(ans) """ n = int(input()) tv = [list(map(int, input().split())) for _ in range(n)] n = sum(t for t, _ in tv) % MOD def f(x): if x == -1: return 0 ret = 0 three = x * (x + 1) * pow(2, MOD - 2, MOD) three = pow(three, 2, MOD) ret -= three ret %= MOD two = x * (x + 1) * (2 * x + 1) * pow(6, MOD - 2, MOD) ret += (n - 3) * two ret %= MOD one = x * (x + 1) * pow(2, MOD - 2, MOD) ret += (3 * n - 2) * one ret %= MOD ret += 2 * n * (x + 1) ret *= pow(2, MOD - 2, MOD) return ret % MOD for i in range(x + 1): ret += (n - i) * (i + 1) * (i + 2) // 2 return ret ans = 0 l = 0 for t, v in tv: ans += v * (f(l + t - 1) - f(l - 1)) ans %= MOD l += t print(ans)