結果

問題 No.24 数当てゲーム
ユーザー drymousedrymouse
提出日時 2019-12-14 12:49:54
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 1,129 bytes
コンパイル時間 694 ms
コンパイル使用メモリ 28,964 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-10 11:51:13
合計ジャッジ時間 1,449 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 0 ms
4,376 KB
testcase_04 AC 0 ms
4,380 KB
testcase_05 AC 0 ms
4,384 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 0 ms
4,380 KB
testcase_08 AC 0 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void YES(int gue[], int *ans);
void NO(int gue[], int *ans);

int main(void) {
    int N;
    int k[4] = {0};
    int Ans[10] = {0};
    char R[4];
    int m = 0;
    int s = 0;
    scanf("%d", &N);

    for (int i = 0; i < N; i++) {
        
        for (int j = 0; j < 4; j++) {
            scanf("%d", &k[j]);
        }
        scanf("%s", R);
        if (R[0] == 'Y') {
            YES(k, Ans);
        } else if (R[0] == 'N') {
            NO(k, Ans);
        }
    }
    for (int i = 0; i < 10; i++) {
        if (Ans[i] >= m) {
            m = Ans[i];
            s = i;
        }
    }
    printf("%d\n", s);
    
    return EXIT_SUCCESS;
}

void YES(int gue[], int *ans) {
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 10; j++) {
            if (j == gue[i]) {
                (*(ans+j))++;
            }
        }
    }
    return;
}

void NO(int gue[], int *ans) {
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 10; j++) {
            if (j == gue[i]) {
                (*(ans+j))--;
            }
        }
    }
    return;
}
0