結果

問題 No.8044 April Sum of Odd
ユーザー Mister
提出日時 2020-08-01 11:21:06
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 562 bytes
コンパイル時間 859 ms
コンパイル使用メモリ 68,964 KB
最終ジャッジ日時 2025-01-12 12:28:43
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using lint = long long;

void solve() {
    int n, m;
    std::cin >> n >> m;

    int cnt = 0;
    lint sum = 0;
    while (n--) {
        lint x;
        std::cin >> x;

        if (x % 2 == 0) {
            if (cnt >= m) std::cout << sum << "\n";
            cnt = 0;
            sum = 0;
        } else {
            ++cnt;
            sum += x;
        }
    }

    if (cnt >= m) std::cout << sum << "\n";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0