結果

問題 No.571 3人兄弟(その2)
ユーザー @abcde@abcde
提出日時 2019-02-24 12:42:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 763 bytes
コンパイル時間 1,351 ms
コンパイル使用メモリ 146,604 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-23 11:28:19
合計ジャッジ時間 2,333 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

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

struct brother{
    char n; // メンバー名.
    int  h; // 身長.
    int  w; // 体重.
    bool operator<(const brother& another) const { return (h > another.h) 
    || (h == another.h && w < another.w); }
};

int main() {
    
    // 1. 入力情報取得.
    brother b[3];
    for(int i = 0; i < 3; i++){
        int h, w;
        char n = 'A' + i;
        cin >> h >> w;
        b[i].n = n, b[i].h = h, b[i].w = w;
    }
    
    // 2. 下記条件で, sort.
    // ① 身長がより高いほうが優れている
    // ② 長が同じであれば体重が軽いほうが優れている
    sort(b, b + 3);

    // 3. 終了.
    for(int i = 0; i < 3; i++) cout << b[i].n << endl;
    return 0;
    
}
0