結果
問題 | No.79 過小評価ダメ・ゼッタイ |
ユーザー | tom_tom_tom |
提出日時 | 2015-11-11 08:51:36 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 540 ms / 5,000 ms |
コード長 | 3,976 bytes |
コンパイル時間 | 4,231 ms |
コンパイル使用メモリ | 89,772 KB |
実行使用メモリ | 48,264 KB |
最終ジャッジ日時 | 2024-06-26 07:45:28 |
合計ジャッジ時間 | 12,593 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 218 ms
45,908 KB |
testcase_01 | AC | 502 ms
48,156 KB |
testcase_02 | AC | 137 ms
41,608 KB |
testcase_03 | AC | 125 ms
41,520 KB |
testcase_04 | AC | 128 ms
41,420 KB |
testcase_05 | AC | 470 ms
48,264 KB |
testcase_06 | AC | 138 ms
41,348 KB |
testcase_07 | AC | 125 ms
40,224 KB |
testcase_08 | AC | 137 ms
41,612 KB |
testcase_09 | AC | 137 ms
41,392 KB |
testcase_10 | AC | 139 ms
41,792 KB |
testcase_11 | AC | 140 ms
41,856 KB |
testcase_12 | AC | 130 ms
40,448 KB |
testcase_13 | AC | 136 ms
41,532 KB |
testcase_14 | AC | 417 ms
48,116 KB |
testcase_15 | AC | 300 ms
47,640 KB |
testcase_16 | AC | 484 ms
47,236 KB |
testcase_17 | AC | 277 ms
47,676 KB |
testcase_18 | AC | 475 ms
48,096 KB |
testcase_19 | AC | 407 ms
47,952 KB |
testcase_20 | AC | 494 ms
48,216 KB |
testcase_21 | AC | 205 ms
44,024 KB |
testcase_22 | AC | 373 ms
47,928 KB |
testcase_23 | AC | 540 ms
47,900 KB |
testcase_24 | AC | 509 ms
47,720 KB |
ソースコード
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]); } } }