結果

問題 No.8044 April Sum of Odd
コンテスト
ユーザー KiYugadgeter
提出日時 2019-04-01 22:45:00
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 505 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 289 ms
コンパイル使用メモリ 74,288 KB
実行使用メモリ 9,896 KB
最終ジャッジ日時 2026-09-30 15:26:40
合計ジャッジ時間 2,136 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other WA * 3 RE * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:7:12: warning: 'n' is used uninitialized [-Wuninitialized]
    7 |     int v[n];
      |            ^
main.cpp:4:9: note: 'n' declared here
    4 |     int n, m;
      |         ^

ソースコード

diff #
raw source code

#include <iostream>

int main() {
    int n, m;
    int u = 0;
    int x = 0;
    int v[n];
    std::cin >> n >> m;
    for (int i = 0; i < n; i++) {
        std::cin >> v[i];
        if (v[i] % 2 != 0) {
            u += v[i];
            x++;
        }
        else if (v[i] % 2 == 0) {
            if (x >= m) {
                std::cout << u << std::endl;
            }
            u = 0;
            x = 0;
        }
    }
    if (x >= m) {
        std::cout << u << std::endl;
    }
    return 0;
}
0