結果

問題 No.293 4>7の世界
ユーザー sue_charosue_charo
提出日時 2017-04-30 16:12:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 850 bytes
コンパイル時間 3,246 ms
コンパイル使用メモリ 72,408 KB
実行使用メモリ 57,408 KB
最終ジャッジ日時 2023-08-28 22:20:01
合計ジャッジ時間 7,202 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,384 KB
testcase_01 AC 117 ms
55,928 KB
testcase_02 AC 119 ms
55,764 KB
testcase_03 AC 118 ms
55,688 KB
testcase_04 AC 119 ms
55,908 KB
testcase_05 AC 117 ms
55,700 KB
testcase_06 AC 117 ms
55,620 KB
testcase_07 AC 117 ms
55,676 KB
testcase_08 AC 117 ms
55,808 KB
testcase_09 AC 119 ms
55,896 KB
testcase_10 AC 118 ms
55,712 KB
testcase_11 AC 118 ms
55,328 KB
testcase_12 AC 117 ms
55,696 KB
testcase_13 AC 120 ms
55,808 KB
testcase_14 AC 118 ms
55,724 KB
testcase_15 AC 118 ms
57,408 KB
testcase_16 AC 116 ms
55,408 KB
testcase_17 AC 118 ms
55,876 KB
testcase_18 AC 119 ms
55,764 KB
testcase_19 AC 117 ms
55,772 KB
testcase_20 AC 120 ms
55,636 KB
testcase_21 AC 120 ms
56,180 KB
testcase_22 AC 120 ms
55,620 KB
testcase_23 AC 119 ms
55,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Yuki293 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        System.out.println(less(a, b) ? a : b);
    }
    
    public static boolean less(String a, String b) {
        char[] l_a = a.toCharArray();
        char[] l_b = b.toCharArray();
        if (l_a.length != l_b.length) {
            return l_a.length > l_b.length;
        }
        int n = l_a.length;
        for (int i = 0; i < n; i++) {
            if (l_a[i] != l_b[i]) {
                if (l_a[i] == '4' && l_b[i] == '7' || l_a[i] == '7' && l_b[i] == '4') {
                    return l_a[i] < l_b[i];
                } else {
                    return l_a[i] > l_b[i];
                }
            }
        }
        return true;
    }
}
0