問題一覧 > 教育的問題

No.8044 April Sum of Odd

レベル : / AI推定難易度 : 275 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 186
作問者 : gotutiyan / テスター : ciel
お気に入りにしたユーザー ProblemId : 2607 / 自分の提出
問題文最終更新日: 2019-04-01 21:30:28
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder April Fool Contest 2019 (順位表) の他の問題:

Problem Statement

Integers $N,M$ and an integer sequence of length $N$ are given, separated by spaces. The elements are $A_1 A_2 \dots A_N$.
For each of all the segments of this sequence in which M or more odd numbers appear consecutively, output the sum of its elements.
It is guaranteed that there is at least one answer to output.

Input

$N M$
$A_1 A_2 \dots A_N$

$1 \le N \le 10$$5$
$1 \le M \le N$
$0 \le A_i \le 10$$9$

Output

$S_1$
$S_2$
$\dots$
$S_T$

The output consists of T lines.
Here, T is the number of segments in which M or more odd numbers appear consecutively.
For the T segments, output the sum of each, separated by newlines.

Sample

Sample 1
Input
5 3
2 1 3 5 4
Output
9

The only place where three or more odd numbers appear consecutively is {1,3,5}, and its sum is 9.

Sample 2
Input
6 2
1 3 2 4 5 7
Output
4
12

Two or more odd numbers appear consecutively in the two places {1,3} {5,7}, so output their respective sums 4,12 in this order.

Sample 3
Input
10 1
1000000000 99999999 99999998 99999999 99999999 99999999 2 786567 564391 6547849
Output
99999999
299999997
7898807

{99999999}
{99999999 99999999 99999999}
{786567 564391 6547849} Output for these three segments in this order.
Note that the values may not fit in a 32-bit integer.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。