結果

問題 No.8044 April Sum of Odd
ユーザー xuzijian629
提出日時 2019-04-01 21:27:40
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 424 bytes
コンパイル時間 2,098 ms
コンパイル使用メモリ 191,920 KB
最終ジャッジ日時 2025-01-07 00:52:48
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    long long sum = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a & 1) {
            sum += a;
            cnt++;
        } else {
            if (cnt >= m) cout << sum << '\n';
            sum = 0;
            cnt = 0;
        }
    }
    if (cnt >= m) cout << sum << '\n';
}
0