結果

問題 No.2717 Sum of Subarray of Subsequence
ユーザー Mao-betaMao-beta
提出日時 2024-04-18 14:42:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 380 ms / 2,000 ms
コード長 918 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 82,768 KB
実行使用メモリ 104,448 KB
最終ジャッジ日時 2024-04-18 14:42:46
合計ジャッジ時間 6,600 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
57,476 KB
testcase_01 AC 45 ms
56,556 KB
testcase_02 AC 46 ms
56,932 KB
testcase_03 AC 47 ms
55,716 KB
testcase_04 AC 46 ms
56,640 KB
testcase_05 AC 46 ms
56,780 KB
testcase_06 AC 47 ms
56,644 KB
testcase_07 AC 46 ms
57,096 KB
testcase_08 AC 46 ms
56,040 KB
testcase_09 AC 349 ms
103,168 KB
testcase_10 AC 380 ms
103,284 KB
testcase_11 AC 344 ms
103,188 KB
testcase_12 AC 338 ms
103,364 KB
testcase_13 AC 327 ms
103,524 KB
testcase_14 AC 361 ms
103,164 KB
testcase_15 AC 355 ms
103,928 KB
testcase_16 AC 351 ms
103,292 KB
testcase_17 AC 368 ms
103,256 KB
testcase_18 AC 348 ms
103,288 KB
testcase_19 AC 347 ms
103,232 KB
testcase_20 AC 45 ms
56,864 KB
testcase_21 AC 46 ms
55,716 KB
testcase_22 AC 374 ms
103,508 KB
testcase_23 AC 332 ms
104,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math
import bisect
from heapq import heapify, heappop, heappush
from collections import deque, defaultdict, Counter
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product

sys.set_int_max_str_digits(10 ** 6)
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD99 = 998244353

input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()
SMI = lambda: input().split()
SLI = lambda: list(SMI())
EI = lambda m: [NLI() for _ in range(m)]


def main():
    N = NI()
    A = NLI()
    ans = 0
    for i, a in enumerate(A):
        tmp = 0
        tmp += pow(2, N-1, MOD99)
        tmp += (N-1) * pow(2, N-2, MOD99)
        tmp += i * (N-1-i) * pow(2, N-3, MOD99)
        ans += tmp * a
        ans %= MOD99
    print(ans)


if __name__ == "__main__":
    main()
0