Submission #1368274
Source Code Expand
import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int A = sc.nextInt(); int B = sc.nextInt(); int count = 0; while (A != B) { count++; int diff = Math.abs(B - A); int operation; if (diff >= 8) { operation = 10; } else if (diff > 3) { operation = 5; } else { operation = 1; } if (B - A > 0) { A += operation; } else { A -= operation; } } System.out.println(count); } private static boolean isDebug = System.getProperty("sun.desktop") != null; private static void debug(Object... o) { if (isDebug) { System.err.println(Arrays.deepToString(o)); } } public static class Scanner { private BufferedInputStream inputStream; public Scanner(InputStream in) { inputStream = new BufferedInputStream(in); } public int nextInt() throws IOException { int num = 0; int read = skip(); do { num = num * 10 + (read - 0x30); } while ((read = inputStream.read()) > 0x20); return num; } public void fill(int[] a) throws IOException { for (int i = 0; i < a.length; i++) { a[i] = nextInt(); } } public void fill(int[] a, int[] b) throws IOException { if (a.length != b.length) { throw new IllegalArgumentException(); } for (int i = 0; i < a.length; i++) { a[i] = nextInt(); b[i] = nextInt(); } } public long nextLong() throws IOException { long num = 0; int read = skip(); do { num = num * 10 + (read - 0x30); } while ((read = inputStream.read()) > 0x20); return num; } public void fill(long[] a) throws IOException { for (int i = 0; i < a.length; i++) { a[i] = nextLong(); } } public void fill(long[] a, long[] b) throws IOException { if (a.length != b.length) { throw new IllegalArgumentException(); } for (int i = 0; i < a.length; i++) { a[i] = nextLong(); b[i] = nextLong(); } } public long[] nextLong(int n) throws IOException { long[] array = new long[n]; for (int i = 0; i < n; i++) { array[i] = nextLong(); } return array; } public String next() throws IOException { StringBuilder builder = new StringBuilder(); int read = skip(); do { builder.append((char) read); } while ((read = inputStream.read()) > 0x20); return builder.toString(); } private int skip() throws IOException { int read; while ((read = inputStream.read()) <= 0x20) ; return read; } } }
Submission Info
Submission Time | |
---|---|
Task | B - リモコン |
User | YujiSoftware |
Language | Java8 (OpenJDK 1.8.0) |
Score | 100 |
Code Size | 2762 Byte |
Status | AC |
Exec Time | 71 ms |
Memory | 23124 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 00_maxdiff.txt, 00_maxret.txt, 00_sample1.txt, 00_sample2.txt, 00_sample3.txt, 01_rnd_00.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt, 01_rnd_20.txt, 01_rnd_21.txt, 01_rnd_22.txt, 01_rnd_23.txt, 01_rnd_24.txt, 01_rnd_25.txt, 01_rnd_26.txt, 01_rnd_27.txt, 01_rnd_28.txt, 01_rnd_29.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_maxdiff.txt | AC | 68 ms | 18772 KB |
00_maxret.txt | AC | 69 ms | 19152 KB |
00_sample1.txt | AC | 68 ms | 16980 KB |
00_sample2.txt | AC | 69 ms | 23124 KB |
00_sample3.txt | AC | 68 ms | 19156 KB |
01_rnd_00.txt | AC | 68 ms | 19540 KB |
01_rnd_01.txt | AC | 70 ms | 20948 KB |
01_rnd_02.txt | AC | 68 ms | 18132 KB |
01_rnd_03.txt | AC | 68 ms | 19412 KB |
01_rnd_04.txt | AC | 69 ms | 20948 KB |
01_rnd_05.txt | AC | 70 ms | 22996 KB |
01_rnd_06.txt | AC | 67 ms | 21332 KB |
01_rnd_07.txt | AC | 68 ms | 19540 KB |
01_rnd_08.txt | AC | 68 ms | 19156 KB |
01_rnd_09.txt | AC | 67 ms | 17620 KB |
01_rnd_10.txt | AC | 71 ms | 21332 KB |
01_rnd_11.txt | AC | 68 ms | 18644 KB |
01_rnd_12.txt | AC | 68 ms | 19284 KB |
01_rnd_13.txt | AC | 67 ms | 21204 KB |
01_rnd_14.txt | AC | 68 ms | 19156 KB |
01_rnd_15.txt | AC | 69 ms | 22356 KB |
01_rnd_16.txt | AC | 68 ms | 19028 KB |
01_rnd_17.txt | AC | 68 ms | 19796 KB |
01_rnd_18.txt | AC | 67 ms | 21332 KB |
01_rnd_19.txt | AC | 68 ms | 17492 KB |
01_rnd_20.txt | AC | 69 ms | 21076 KB |
01_rnd_21.txt | AC | 68 ms | 20052 KB |
01_rnd_22.txt | AC | 67 ms | 21076 KB |
01_rnd_23.txt | AC | 69 ms | 22484 KB |
01_rnd_24.txt | AC | 67 ms | 19156 KB |
01_rnd_25.txt | AC | 71 ms | 19028 KB |
01_rnd_26.txt | AC | 67 ms | 18260 KB |
01_rnd_27.txt | AC | 67 ms | 21332 KB |
01_rnd_28.txt | AC | 68 ms | 19156 KB |
01_rnd_29.txt | AC | 68 ms | 19796 KB |