結果

問題 No.99 ジャンピング駒
ユーザー 👑 rin204rin204
提出日時 2020-07-01 14:36:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 5,000 ms
コード長 349 bytes
コンパイル時間 488 ms
コンパイル使用メモリ 64,728 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-12 00:03:49
合計ジャッジ時間 1,498 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
4,352 KB
testcase_01 AC 40 ms
4,348 KB
testcase_02 AC 41 ms
4,348 KB
testcase_03 AC 41 ms
4,348 KB
testcase_04 AC 41 ms
4,348 KB
testcase_05 AC 40 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:19:20: 警告: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized]
   19 |     cout << abs(ans) << endl;
      |                    ^
main.cpp:7:12: 備考: ‘ans’ はここで定義されています
    7 |     int n, ans;
      |            ^~~

ソースコード

diff #

#include <iostream>
#include<string>

using namespace std;
using ll = long long int;
int main(void){
    int n, ans;
    cin >> n;
    ll x;
    for (int i = 0; i < n; i ++){
        cin >> x;
        if (x % 2 == 0){
            ans ++;
        }
        else{
            ans --;
        }
    }
    cout << abs(ans) << endl;
    
    return 0;
}
0