結果

問題 No.2170 Left Addition Machine
ユーザー 👑 rin204rin204
提出日時 2022-11-28 21:12:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 895 ms / 2,000 ms
コード長 662 bytes
コンパイル時間 616 ms
コンパイル使用メモリ 86,256 KB
実行使用メモリ 142,828 KB
最終ジャッジ日時 2023-08-11 12:51:58
合計ジャッジ時間 55,753 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,208 KB
testcase_01 AC 94 ms
71,048 KB
testcase_02 AC 89 ms
71,156 KB
testcase_03 AC 836 ms
134,876 KB
testcase_04 AC 550 ms
78,412 KB
testcase_05 AC 558 ms
97,264 KB
testcase_06 AC 508 ms
99,708 KB
testcase_07 AC 713 ms
101,300 KB
testcase_08 AC 201 ms
96,548 KB
testcase_09 AC 644 ms
86,448 KB
testcase_10 AC 235 ms
78,716 KB
testcase_11 AC 426 ms
102,880 KB
testcase_12 AC 820 ms
134,800 KB
testcase_13 AC 838 ms
135,276 KB
testcase_14 AC 803 ms
135,200 KB
testcase_15 AC 812 ms
135,292 KB
testcase_16 AC 813 ms
135,556 KB
testcase_17 AC 807 ms
135,472 KB
testcase_18 AC 809 ms
135,408 KB
testcase_19 AC 871 ms
135,576 KB
testcase_20 AC 802 ms
135,520 KB
testcase_21 AC 654 ms
78,752 KB
testcase_22 AC 643 ms
78,856 KB
testcase_23 AC 640 ms
78,752 KB
testcase_24 AC 622 ms
78,824 KB
testcase_25 AC 649 ms
78,764 KB
testcase_26 AC 639 ms
78,636 KB
testcase_27 AC 632 ms
78,760 KB
testcase_28 AC 647 ms
78,660 KB
testcase_29 AC 632 ms
78,740 KB
testcase_30 AC 734 ms
130,036 KB
testcase_31 AC 694 ms
127,620 KB
testcase_32 AC 731 ms
130,092 KB
testcase_33 AC 730 ms
130,004 KB
testcase_34 AC 724 ms
129,836 KB
testcase_35 AC 749 ms
130,044 KB
testcase_36 AC 691 ms
129,972 KB
testcase_37 AC 738 ms
130,008 KB
testcase_38 AC 701 ms
129,928 KB
testcase_39 AC 589 ms
78,592 KB
testcase_40 AC 583 ms
78,564 KB
testcase_41 AC 577 ms
78,448 KB
testcase_42 AC 573 ms
78,588 KB
testcase_43 AC 566 ms
78,612 KB
testcase_44 AC 579 ms
78,448 KB
testcase_45 AC 572 ms
78,344 KB
testcase_46 AC 576 ms
78,620 KB
testcase_47 AC 577 ms
78,600 KB
testcase_48 AC 715 ms
129,236 KB
testcase_49 AC 742 ms
129,844 KB
testcase_50 AC 734 ms
130,076 KB
testcase_51 AC 716 ms
129,600 KB
testcase_52 AC 736 ms
129,816 KB
testcase_53 AC 754 ms
129,616 KB
testcase_54 AC 723 ms
129,300 KB
testcase_55 AC 766 ms
129,420 KB
testcase_56 AC 770 ms
129,820 KB
testcase_57 AC 823 ms
142,540 KB
testcase_58 AC 801 ms
142,632 KB
testcase_59 AC 831 ms
142,716 KB
testcase_60 AC 895 ms
142,608 KB
testcase_61 AC 848 ms
142,664 KB
testcase_62 AC 860 ms
142,828 KB
testcase_63 AC 809 ms
142,756 KB
testcase_64 AC 866 ms
142,624 KB
testcase_65 AC 796 ms
142,676 KB
testcase_66 AC 280 ms
78,616 KB
testcase_67 AC 726 ms
132,700 KB
testcase_68 AC 793 ms
142,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_right
MOD = 998244353

n, Q = map(int, input().split())
A = list(map(int, input().split()))
ind = [0]
for i in range(1, n):
    if A[i - 1] >= A[i]:
        ind.append(i)

cum = [0]
times = 1
for a in A:
    cum.append((cum[-1] + a * times) % MOD)
    times *= 2
    times %= MOD

inv2 = [1]
inv = pow(2, MOD - 2, MOD)
for _ in range(n):
    inv2.append(inv2[-1] * inv % MOD)

for _ in range(Q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    p = bisect_right(ind, r)
    l = max(l, ind[p - 1])
    ans = A[l]
    if l != r:
        ans += (cum[r + 1] - cum[l + 1]) * inv2[l + 1] % MOD
        ans %= MOD

    print(ans)
0