Submission #864096
Source Code Expand
public class Main { public static void main(String[] args) throws java.io.IOException { new Main().run(); } private void run() throws java.io.IOException { MySystemScanner sc = new MySystemScanner(); // MySystemScanner sc = new MySystemScanner("input.txt"); /////////////////////////////////////////////////////////////// while (sc.getLine() != null) { System.out.println(sc.getInt() - sc.getInt()); } /////////////////////////////////////////////////////////////// sc.close(); // sc2.close(); } class MySystemScanner { /** * @param streamReader * InputStreamReader based on System.in * @param reader * BufferedReader based on streamReader * @param currentString * String current using * @param splitCurrentString * split currentString using delimiter * @param nextIndex * index of next element * @param delimiter * delimiter used for split */ private java.io.InputStreamReader streamReader = new java.io.InputStreamReader(System.in); private java.io.BufferedReader reader = new java.io.BufferedReader(streamReader); private String currentString = null; private String[] splitCurrentString = null; private int nextIndex = 0; private String delimiter = "[ -]+"; /* simple Constructor */ public MySystemScanner() { initialize(); } /* Constructor using FileStream */ public MySystemScanner(String FileName) { close(); try { streamReader = new java.io.FileReader(FileName); reader = new java.io.BufferedReader(streamReader); initialize(); } catch (java.io.FileNotFoundException e) { } } /* initialize :: split & reset nextIndex */ private void initialize() { // if error occurred, retry try { currentString = reader.readLine(); if (currentString != null) { splitCurrentString = currentString.split(delimiter); nextIndex = 0; } } catch (java.io.IOException e) { initialize(); } } /* setDelimiter :: to set delimiter & initialize */ public void setdelimiter(String designatedDelimiter) { delimiter = designatedDelimiter.toString(); initialize(); } /* hasNext :: there is next element or not */ public boolean hasNext() { return currentString != null; } /* goNextLine :: go to next Line */ public void goNextLine() { initialize(); } /* getInt :: return nextInteger */ public int getInt() { int ret = 0; if (currentString != null && hasNext()) { ret = Integer.parseInt(splitCurrentString[nextIndex++]); } else { errMessage("Cant Return INTEGER !"); } if (nextIndex == splitCurrentString.length) { goNextLine(); } return ret; } /* getDouble :: return nextDouble */ public double getDouble() { double ret = 0; if (currentString != null && hasNext()) { ret = Double.parseDouble(splitCurrentString[nextIndex++]); } else { errMessage("Cant Return DOUBLE !"); } if (nextIndex == splitCurrentString.length) { goNextLine(); } return ret; } /* getString :: return nextString */ public String getString() { String ret = null; if (currentString != null && hasNext()) { ret = splitCurrentString[nextIndex++].toString(); } else { errMessage("Cant Return STRING !"); } if (nextIndex == splitCurrentString.length) { goNextLine(); } return ret; } /* getLine :: return currentString */ public String getLine() { return currentString; } /* isNextInt :: if can next element is Integer or not */ public boolean isNextInt() { try { Integer.parseInt(splitCurrentString[nextIndex]); } catch (NumberFormatException e) { return false; } return true; } /* isNextDouble :: if can next element is Double or not */ public boolean isNextDouble() { try { Double.parseDouble(splitCurrentString[nextIndex]); } catch (NumberFormatException e) { return false; } return true; } /* errMessage :: to put error message */ private void errMessage(String type) { System.out.println("ERROR:" + type); System.out.println("Current Condition"); System.out.println("* CurrentString:" + currentString); System.out.println("* CurrentSource:" + splitCurrentString[nextIndex - 1]); System.out.println("Exit..."); close(); System.exit(-1); } /* close Method :: to close stream */ /* !! MUST CALL THIS METHOD !! */ public void close() { try { reader.close(); streamReader.close(); } catch (java.io.IOException e) { System.out.println("Error: Cant close stream!"); System.out.println("Exit."); System.exit(-1); } } } }
Submission Info
Submission Time | |
---|---|
Task | A - 積雪深差 |
User | oblivion |
Language | Java (OpenJDK 1.7.0) |
Score | 100 |
Code Size | 4964 Byte |
Status | AC |
Exec Time | 432 ms |
Memory | 20904 KB |
Judge Result
Set Name | all | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
all | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_01.txt | AC | 432 ms | 20900 KB |
00_sample_02.txt | AC | 316 ms | 20892 KB |
00_sample_03.txt | AC | 330 ms | 20852 KB |
test_01.txt | AC | 346 ms | 20868 KB |
test_02.txt | AC | 346 ms | 20856 KB |
test_03.txt | AC | 319 ms | 20776 KB |
test_04.txt | AC | 330 ms | 20856 KB |
test_05.txt | AC | 311 ms | 20828 KB |
test_06.txt | AC | 317 ms | 20888 KB |
test_07.txt | AC | 316 ms | 20824 KB |
test_08.txt | AC | 317 ms | 20784 KB |
test_09.txt | AC | 314 ms | 20764 KB |
test_10.txt | AC | 321 ms | 20868 KB |
test_11.txt | AC | 337 ms | 20828 KB |
test_12.txt | AC | 335 ms | 20904 KB |
test_13.txt | AC | 325 ms | 20900 KB |
test_14.txt | AC | 343 ms | 20764 KB |
test_15.txt | AC | 315 ms | 20844 KB |
test_16.txt | AC | 315 ms | 20892 KB |
test_17.txt | AC | 315 ms | 20768 KB |