結果

問題 No.293 4>7の世界
ユーザー tom_tom_tomtom_tom_tom
提出日時 2015-11-11 08:12:52
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 4,070 bytes
コンパイル時間 6,286 ms
コンパイル使用メモリ 91,108 KB
実行使用メモリ 55,928 KB
最終ジャッジ日時 2023-10-11 15:35:55
合計ジャッジ時間 9,814 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,736 KB
testcase_01 AC 129 ms
55,556 KB
testcase_02 AC 127 ms
55,904 KB
testcase_03 WA -
testcase_04 AC 126 ms
55,700 KB
testcase_05 WA -
testcase_06 AC 127 ms
55,740 KB
testcase_07 AC 129 ms
55,784 KB
testcase_08 AC 128 ms
55,724 KB
testcase_09 WA -
testcase_10 AC 127 ms
55,860 KB
testcase_11 AC 127 ms
55,828 KB
testcase_12 AC 127 ms
55,928 KB
testcase_13 AC 127 ms
55,736 KB
testcase_14 AC 128 ms
55,780 KB
testcase_15 WA -
testcase_16 AC 126 ms
55,840 KB
testcase_17 AC 127 ms
55,912 KB
testcase_18 AC 127 ms
55,784 KB
testcase_19 AC 131 ms
55,496 KB
testcase_20 AC 129 ms
55,860 KB
testcase_21 AC 129 ms
55,496 KB
testcase_22 AC 128 ms
55,696 KB
testcase_23 AC 129 ms
55,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package me.yukicoder;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;

public class YukiCoder293 {
    private static boolean LOCAL = System.getenv().keySet().stream().anyMatch(key -> key.startsWith("JAVA_MAIN_CLASS"));


    public static void run() {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String[] org = s.split(" ");
        String l = org[0];
        String r = org[1];
        s = s.replace('4', 'A');
        s = s.replace('7', '4');
        s = s.replace('A', '7');
        String[] ss = s.split(" ");
        long a = Long.parseLong(ss[0]);
        long b = Long.parseLong(ss[1]);
        boolean left = false;
        if (a > b) {
            left = true;
        }

        System.out.println(left ? l : r);
    }

    private static TestCase getTest1() {
        return new TestCase("4", "4 7");
    }

    private static TestCase getTest2() {
        return new TestCase("5", "5 7");
    }

    private static TestCase getTest3() {
        return new TestCase("170", "40 170");
    }

    private static TestCase getTest4() {
        return new TestCase("1234567890", "1237564890 1234567890");
    }

    private static TestCase getTest5() {
        return new TestCase("", "");
    }


    public static void main(String[] args) {
        perform();
    }

    private static void perform() {
        if (LOCAL) {
            List<TestCase> tests = getTests();
            boolean passed = true;
            int index = 1;
            for (TestCase testCase : getTests()) {
                String input = Arrays.stream(testCase.inputs).collect(joining(System.lineSeparator()));
                InputStream in = new ByteArrayInputStream(input.getBytes());
                System.setIn(in);

                PrintStream sout = System.out;
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                PrintStream ps = new PrintStream(baos);


                System.setOut(ps);
                try {
                    run();
                } finally {
                    System.setOut(sout);
                }

                System.out.flush();

                String actual = baos.toString().trim();
                String expect = testCase.expect;
                boolean match = expect != null && expect.equals(actual);

                System.out.println("------------------------ " + index++ + "/" + tests.size() + " " + (match ? "PASS" : "FAIL"));
                System.out.println("INPUT: " + input);
                System.out.println("RESULT: " + match);
                System.out.println("EXPECTED: " + expect + ":");
                System.out.println("ACTUAL: " + actual + ":");

                if (!match) passed = false;
            }

            System.out.println("\n==== SUMMARY ==== ");
            System.out.println(passed ? "PASS" : "FAIL");
        } else {
            run();
        }
    }


    public static List<TestCase> getTests() {
        List<TestCase> testCases = new ArrayList<>();
        testCases.add(getTest1());
        testCases.add(getTest2());
        testCases.add(getTest3());
        testCases.add(getTest4());
        testCases.add(getTest5());
        return testCases.stream().filter(t -> !t.ignore()).collect(toList());
    }

    private static class TestCase {
        String expect;
        String[] inputs;

        public TestCase(String expect, String[] inputs) {
            this.expect = expect;
            this.inputs = inputs;
        }

        public TestCase(String expect, String input) {
            this.expect = expect;
            this.inputs = new String[]{input};
        }

        public boolean ignore() {
            return "".equals(expect) && inputs.length == 1 && "".equals(inputs[0]);
        }
    }

}
0