結果

問題 No.571 3人兄弟(その2)
ユーザー conankunconankun
提出日時 2017-10-13 23:59:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,407 bytes
コンパイル時間 405 ms
コンパイル使用メモリ 52,100 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-11 00:37:33
合計ジャッジ時間 1,161 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 0 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

using namespace std;

// int max2(int x, int y) {
//     return x > y ? x : y;
// }

// int max3(int x, int y, int z) {
//     x = max2(x, y);
//     return max2(x, z);
// }

// int min2(int x, int y) {
//     return x < y ? x : y;
// }

// int min3(int x, int y, int z) {
//     x = min2(x, y);
//     return min2(x, z);
// }

struct Brother {
    int height;
    int weight;
    char name;
};

Brother betterBrother(Brother a, Brother b) {
    if (a.height == b.height) {
        return a.weight < b.weight ? a : b;
    }
    return a.height > b.height ? a : b;
}

Brother worseBrother(Brother a, Brother b) {
    if (a.height == b.height) {
        return a.weight > b.weight ? a : b;
    }
    return a.height < b.height ? a : b;
}

int main() {
    Brother A = { 0, 0, 'A', };
    Brother B = { 0, 0, 'B', };
    Brother C = { 0, 0, 'C', };
    cin >> A.height >> A.weight >> B.height >> B.weight >> C.height >> C.weight;

    Brother best = betterBrother(A, B);
    best = betterBrother(best, C);

    Brother worst = worseBrother(A, B);
    worst = worseBrother(worst, C);

    cout << best.name << "\n";
    cout << (best.name != 'A' && worst.name != 'A' ? "A" : best.name != 'B' && worst.name != 'B' ? "B" : "C") << "\n";
    cout << worst.name << "\n";

    int a;
    cin >> a;

    return 0;
}
0