結果
問題 |
No.2369 Some Products
|
ユーザー |
![]() |
提出日時 | 2025-04-15 22:22:48 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 821 bytes |
コンパイル時間 | 187 ms |
コンパイル使用メモリ | 81,692 KB |
実行使用メモリ | 84,796 KB |
最終ジャッジ日時 | 2025-04-15 22:25:09 |
合計ジャッジ時間 | 4,262 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 1 TLE * 1 -- * 12 |
ソースコード
MOD = 998244353 def main(): import sys input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr += 1 P = list(map(int, input[ptr:ptr+N])) ptr += N Q = int(input[ptr]) ptr += 1 for _ in range(Q): A = int(input[ptr]) B = int(input[ptr+1]) K = int(input[ptr+2]) ptr +=3 A -= 1 # Convert to 0-based index B -= 1 sub = P[A:B+1] L = B - A + 1 if K > L: print(0) continue dp = [0] * (K + 1) dp[0] = 1 current_max = 0 for num in sub: current_max = min(current_max + 1, K) for k in range(current_max, 0, -1): dp[k] = (dp[k] + dp[k-1] * num) % MOD print(dp[K] % MOD) if __name__ == "__main__": main()