結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー tom_tom_tomtom_tom_tom
提出日時 2015-11-11 08:51:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 429 ms / 5,000 ms
コード長 3,976 bytes
コンパイル時間 4,398 ms
コンパイル使用メモリ 90,068 KB
実行使用メモリ 60,764 KB
最終ジャッジ日時 2023-09-08 14:40:19
合計ジャッジ時間 11,592 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 206 ms
58,952 KB
testcase_01 AC 418 ms
59,644 KB
testcase_02 AC 125 ms
55,532 KB
testcase_03 AC 126 ms
55,776 KB
testcase_04 AC 122 ms
55,696 KB
testcase_05 AC 427 ms
60,744 KB
testcase_06 AC 124 ms
56,088 KB
testcase_07 AC 126 ms
55,520 KB
testcase_08 AC 125 ms
55,908 KB
testcase_09 AC 128 ms
55,532 KB
testcase_10 AC 126 ms
55,784 KB
testcase_11 AC 125 ms
55,876 KB
testcase_12 AC 121 ms
55,932 KB
testcase_13 AC 124 ms
55,536 KB
testcase_14 AC 368 ms
60,608 KB
testcase_15 AC 290 ms
60,088 KB
testcase_16 AC 404 ms
60,632 KB
testcase_17 AC 287 ms
60,572 KB
testcase_18 AC 396 ms
60,472 KB
testcase_19 AC 346 ms
60,764 KB
testcase_20 AC 429 ms
60,636 KB
testcase_21 AC 185 ms
58,416 KB
testcase_22 AC 314 ms
60,680 KB
testcase_23 AC 419 ms
60,652 KB
testcase_24 AC 420 ms
60,416 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;

/**
 * No. 79
 * http://yukicoder.me:8081/problems/202
 * Star 1
 */
public class YukiCoder79 {

    public static void run() {
        Scanner sc = new Scanner(System.in);

        int[] levels = new int[7];
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            int level = sc.nextInt();
            levels[level]++;
        }

        int ans = 0;
        for (int i = 1; i < 7; i++) {
            if (levels[i] >= levels[ans]) {
                ans = i;
            }
        }
        System.out.println(ans);
    }

    private static TestCase getTest1() {
        return new TestCase("2", "5", "2 1 2 3 2");
    }

    private static TestCase getTest2() {
        return new TestCase("3", "5", "1 2 3 3 1");
    }

    private static TestCase getTest3() {
        return new TestCase("6", "10", "5 3 5 6 3 6 2 3 5 6");
    }

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

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


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

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

    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 boolean ignore() {
            return "".equals(expect) && inputs.length == 1 && "".equals(inputs[0]);
        }
    }

}
0