結果

問題 No.2433 Min Increasing Sequence
ユーザー lloyzlloyz
提出日時 2023-08-31 00:08:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 396 ms / 2,000 ms
コード長 604 bytes
コンパイル時間 416 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 163,236 KB
最終ジャッジ日時 2023-08-31 00:08:52
合計ジャッジ時間 14,134 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,500 KB
testcase_01 AC 93 ms
71,668 KB
testcase_02 AC 92 ms
71,524 KB
testcase_03 AC 93 ms
71,616 KB
testcase_04 AC 396 ms
163,236 KB
testcase_05 AC 195 ms
130,800 KB
testcase_06 AC 256 ms
135,508 KB
testcase_07 AC 198 ms
131,564 KB
testcase_08 AC 275 ms
152,316 KB
testcase_09 AC 167 ms
108,680 KB
testcase_10 AC 186 ms
111,800 KB
testcase_11 AC 246 ms
124,392 KB
testcase_12 AC 178 ms
110,204 KB
testcase_13 AC 158 ms
103,104 KB
testcase_14 AC 268 ms
126,372 KB
testcase_15 AC 164 ms
103,400 KB
testcase_16 AC 186 ms
114,336 KB
testcase_17 AC 154 ms
102,940 KB
testcase_18 AC 363 ms
160,232 KB
testcase_19 AC 363 ms
160,248 KB
testcase_20 AC 110 ms
79,056 KB
testcase_21 AC 352 ms
141,708 KB
testcase_22 AC 368 ms
159,836 KB
testcase_23 AC 311 ms
133,172 KB
testcase_24 AC 394 ms
161,472 KB
testcase_25 AC 354 ms
148,924 KB
testcase_26 AC 281 ms
125,804 KB
testcase_27 AC 320 ms
141,056 KB
testcase_28 AC 325 ms
129,840 KB
testcase_29 AC 137 ms
90,968 KB
testcase_30 AC 134 ms
90,464 KB
testcase_31 AC 126 ms
85,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from bisect import bisect_left
import sys
input = sys.stdin.readline

n = int(input())
A = list(map(int, input().split()))
mod = 998244353

setA = set()
idx_list = defaultdict(list)
for i in range(n):
    setA.add(A[i])
    idx_list[A[i]].append(i)
sortA = sorted(A)
ans = 1
idx = -1
for a in sortA:
    L = idx_list[a]
    i = bisect_left(L, idx)
    if i == len(L):
        continue
    if idx != -1:
        ans *= L[i] - idx + 1
        ans %= mod
    for j in range(i, len(L) - 1):
        ans *= L[j + 1] - L[j] + 1
        ans %= mod
    idx = L[-1]
print(ans)
0