結果
| 問題 |
No.3044 よくあるカエルさん
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 15:17:33 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,147 bytes |
| コンパイル時間 | 188 ms |
| コンパイル使用メモリ | 82,240 KB |
| 実行使用メモリ | 844,296 KB |
| 最終ジャッジ日時 | 2025-06-12 15:17:36 |
| 合計ジャッジ時間 | 3,005 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 = [0] * (N + 1)
for i in range(N):
prefix[i+1] = prefix[i] + A[i]
runs = []
current_start = -1
current_length = 0
for i in range(N):
if A[i] % 2 != 0:
if current_length == 0:
current_start = i
current_length += 1
else:
if current_length > 0:
runs.append((current_start, current_length))
current_length = 0
# Add the last run if any
if current_length > 0:
runs.append((current_start, current_length))
# Collect all valid runs and compute their sums
results = []
for start, length in runs:
if length >= M:
end = start + length
s = prefix[end] - prefix[start]
results.append(s)
# Output the results
for res in results:
print(res)
if __name__ == '__main__':
main()
gew1fw