結果

問題 No.24 数当てゲーム
ユーザー hachidesyuhachidesyu
提出日時 2020-07-03 12:50:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 719 bytes
コンパイル時間 1,480 ms
コンパイル使用メモリ 164,808 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-14 22:45:40
合計ジャッジ時間 2,156 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int ans[10];
    for(int i = 0; i < 10; i++){
        ans[i] = 1;
    }

    int N;
    cin >> N;

    int taro[6][4];
    string res[6];

    for(int i = 0; i < N; i++){
        cin >> taro[i][0] >> taro[i][1] >> taro[i][2] >> taro[i][3] >> res[i];
    }

    for(int i = 0; i < N; i++){
        if(res[i]=="NO"){
            for(int j = 0; j < 4; j++) ans[taro[i][j]]--;
        }
        else{
            for(int j = 0; j < 4; j++) ans[taro[i][j]]++;
        }
    } 

    int max = 0;
    int index;
    for(int i = 0; i < 10; i++){
        if(ans[i]>max){
            max = ans[i];
            index = i;
        } 
    }
    cout << index << endl;
}
0