結果

問題 No.24 数当てゲーム
ユーザー wakimiko01000010wakimiko01000010
提出日時 2019-04-11 11:39:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 802 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 66,252 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 11:18:09
合計ジャッジ時間 1,204 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>

using namespace std;

int main()
{
    int n;
    int a[10][4];
    string s[10];
    int cnt[10] = {};
    int max = -10000100;
    int sub;
    
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3] >> s[i];
    }
    
    for (int i = 0; i < n; i++) {
        if (s[i] == "YES") {
            cnt[a[i][0]]++;
            cnt[a[i][1]]++;
            cnt[a[i][2]]++;
            cnt[a[i][3]]++;
        }
        else {
            cnt[a[i][0]]--;
            cnt[a[i][1]]--;
            cnt[a[i][2]]--;
            cnt[a[i][3]]--;
        }
    }
    
    for (int i = 0; i <= 9; i++) {
        if (cnt[i] > max) {
            max = cnt[i];
            sub = i;
        }

    }
    cout << sub << endl;
}
0