Submission #5559051


Source Code Expand

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
    	int x, y, ans = 0;
    	
        void solve(InputReader in, PrintWriter out) {
            // write your code here
        	x = in.nextInt();
        	y = in.nextInt();
        	
        	if (x != 0 && y != 0 && Integer.signum(x) != Integer.signum(y)) {
        		x *= -1;
        		ans++;
        	}
        	
        	ans += y - x >= 0 ? y - x : x - y + 2;
        	
        	out.println(ans);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}

Submission Info

Submission Time
Task A - Simple Calculator
User hatsujime
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 2306 Byte
Status WA
Exec Time 71 ms
Memory 22484 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
AC × 10
WA × 4
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt
Case Name Status Exec Time Memory
0_00.txt AC 70 ms 21076 KB
0_01.txt AC 69 ms 16596 KB
0_02.txt AC 70 ms 21332 KB
1_00.txt AC 70 ms 21460 KB
1_01.txt AC 71 ms 19412 KB
1_02.txt WA 70 ms 22484 KB
1_03.txt WA 70 ms 19540 KB
1_04.txt AC 70 ms 18772 KB
1_05.txt AC 70 ms 18900 KB
1_06.txt WA 68 ms 21460 KB
1_07.txt AC 68 ms 18900 KB
1_08.txt AC 69 ms 18516 KB
1_09.txt WA 70 ms 18900 KB
1_10.txt AC 69 ms 15952 KB