結果

問題 No.2170 Left Addition Machine
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-10-06 15:46:52
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,008 bytes
コンパイル時間 444 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 112,876 KB
最終ジャッジ日時 2024-04-29 05:09:58
合計ジャッジ時間 10,060 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
57,216 KB
testcase_01 AC 37 ms
51,968 KB
testcase_02 AC 37 ms
52,324 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
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 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

Left Addition Machine 想定TLE解法v1

愚直に解く。
O(N^2Q)

"""

import sys
from sys import stdin

def solve(arr): #愚直に解く

    while len(arr) > 1:
        maxind = 0
        for i in range(len(arr)):
            if arr[maxind] < arr[i]:
                maxind = i

        for j in range(maxind):
            arr[j] = (arr[j] + arr[maxind]) % mod

        del arr[maxind]

    return arr[0] % mod

mod = 998244353

#入力を受け取る
N,Q = map(int,stdin.readline().split())

A = list(map(int,stdin.readline().split()))

LR = []

for i in range(Q):
    L,R = map(int,stdin.readline().split())
    LR.append( (L,R) )


#制約チェック
assert 1 <= N <= 2*(10**5)
assert 1 <= Q <= 2*(10**5)
assert len(A) == N
assert len(LR) == Q

for i in range(N):
    assert 0 <= A[i] < mod
for i in range(Q):
    L,R = LR[i]
    assert 1 <= L <= R <= N

ANS = []
for loop in range(Q):
    l,r = LR[loop]
    l -= 1
    r -= 1

    ANS.append(solve(A[l:r+1]))

print ("\n".join(map(str,ANS)))
0