結果
| 問題 |
No.3044 よくあるカエルさん
|
| コンテスト | |
| ユーザー |
qwewe
|
| 提出日時 | 2025-05-14 13:11:01 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,988 bytes |
| コンパイル時間 | 217 ms |
| コンパイル使用メモリ | 82,376 KB |
| 実行使用メモリ | 67,656 KB |
| 最終ジャッジ日時 | 2025-05-14 13:12:57 |
| 合計ジャッジ時間 | 2,198 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 1 |
| other | RE * 20 |
ソースコード
# Equivalent Python code for the same logic.
import sys
def solve():
# Read N and M from input line, split by space, convert to integers.
N, M = map(int, sys.stdin.readline().split())
# Read the sequence A from input line, split by space, convert elements to integers.
A = list(map(int, sys.stdin.readline().split()))
# Variables to track the current block of odd numbers
current_start_idx = -1 # Start index of the current block, -1 if not in a block
current_sum = 0 # Sum of elements in the current block. Python ints handle large numbers automatically.
# Iterate through the sequence using 0-based indices
for i in range(N):
# Check if A[i] is odd
if A[i] % 2 != 0:
# If this is the start of a new block
if current_start_idx == -1:
current_start_idx = i
# Add to the running sum
current_sum += A[i]
else: # A[i] is even (including 0)
# If we were inside a block of odds
if current_start_idx != -1:
# Block ended at index i-1. Calculate its length.
# Length = (i-1) - current_start_idx + 1 = i - current_start_idx
block_length = i - current_start_idx
# Check if length is sufficient
if block_length >= M:
print(current_sum)
# Reset state
current_start_idx = -1
current_sum = 0
# If not inside a block, do nothing.
# After loop, check if the last block extended to the end
if current_start_idx != -1:
# Block ends at N-1. Calculate its length.
# Length = (N-1) - current_start_idx + 1 = N - current_start_idx
block_length = N - current_start_idx
# Check if length is sufficient
if block_length >= M:
print(current_sum)
# Call the main function to run the solution
solve()
qwewe