結果
| 問題 |
No.3044 よくあるカエルさん
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 20:23:17 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,128 bytes |
| コンパイル時間 | 685 ms |
| コンパイル使用メモリ | 81,784 KB |
| 実行使用メモリ | 843,768 KB |
| 最終ジャッジ日時 | 2025-06-12 20:23:54 |
| 合計ジャッジ時間 | 2,744 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 1 |
| other | MLE * 1 -- * 19 |
ソースコード
def main():
import sys
input = sys.stdin.read().split()
idx = 0
N = int(input[idx])
idx += 1
M = int(input[idx])
idx += 1
A = list(map(int, input[idx:idx+N]))
idx += N
# Compute prefix sums
prefix_sum = [0] * (N + 1)
for i in range(N):
prefix_sum[i+1] = prefix_sum[i] + A[i]
result = []
in_run = False
start = 0
for i in range(N):
if A[i] % 2 == 1:
if not in_run:
start = i
in_run = True
else:
if in_run:
end = i - 1
run_length = end - start + 1
if run_length >= M:
s = prefix_sum[end + 1] - prefix_sum[start]
result.append(s)
in_run = False
# Check if the last run is still active
if in_run:
end = N - 1
run_length = end - start + 1
if run_length >= M:
s = prefix_sum[end + 1] - prefix_sum[start]
result.append(s)
# Print the results
for num in result:
print(num)
if __name__ == "__main__":
main()
gew1fw