結果
問題 | No.571 3人兄弟(その2) |
ユーザー |
![]() |
提出日時 | 2017-10-13 23:59:05 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,407 bytes |
コンパイル時間 | 452 ms |
コンパイル使用メモリ | 56,296 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-17 11:53:17 |
合計ジャッジ時間 | 1,082 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
#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;}