結果

問題 No.99 ジャンピング駒
ユーザー alcheminalchemin
提出日時 2019-09-25 10:21:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 339 bytes
コンパイル時間 1,687 ms
コンパイル使用メモリ 166,352 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 18:59:34
合計ジャッジ時間 2,585 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:20:22: warning: 'even' may be used uninitialized [-Wmaybe-uninitialized]
   20 |     cout << abs(even - odd) << endl;
      |                 ~~~~~^~~~~
main.cpp:6:12: note: 'even' was declared here
    6 |     int n, even, odd = 0;
      |            ^~~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, even, odd = 0;
    
    cin >> n;
    
    int tmp;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        if(tmp % 2 == 0) {
            even++;
        } else {
            odd++;
        }
    }
    
    cout << abs(even - odd) << endl;
    
    return 0;
}
0