結果

問題 No.8044 April Sum of Odd
ユーザー t33f
提出日時 2019-04-01 22:14:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 369 bytes
コンパイル時間 519 ms
コンパイル使用メモリ 63,232 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-27 03:07:37
合計ジャッジ時間 1,142 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
int main() {
    int n, m; cin >> n >> m;
    int a[n];
    long long sum = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        if (x % 2) { cnt++; sum += x; }
        if (x % 2 == 0 || i == n-1) {
            if (cnt >= m) cout << sum << endl;
            cnt = 0; sum = 0;
        }
    }
}
0