Submission #1041121


Source Code Expand

import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    long X = sc.nextLong();
    long Y = sc.nextLong();
    long ans = Integer.MAX_VALUE;
    if (Y >= X) {
      ans = Y - X;
    }
    if (-Y >= X) {
      ans = Math.min(ans, -Y - X + 1);
    }
    if (Y >= -X) {
      ans = Math.min(ans, Y + X + 1);
    }
    if (-Y >= -X) {
      ans = Math.min(ans, -Y + X + 2);
    }
    System.out.println(ans);
  }

}

Submission Info

Submission Time
Task A - Simple Calculator
User tomerun
Language Java8 (OpenJDK 1.8.0)
Score 300
Code Size 523 Byte
Status AC
Exec Time 138 ms
Memory 10320 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 14
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 138 ms 10320 KB
0_01.txt AC 124 ms 9556 KB
0_02.txt AC 123 ms 9676 KB
1_00.txt AC 126 ms 9680 KB
1_01.txt AC 124 ms 9556 KB
1_02.txt AC 125 ms 9676 KB
1_03.txt AC 132 ms 9556 KB
1_04.txt AC 124 ms 9680 KB
1_05.txt AC 124 ms 9556 KB
1_06.txt AC 128 ms 9672 KB
1_07.txt AC 126 ms 9680 KB
1_08.txt AC 124 ms 9684 KB
1_09.txt AC 130 ms 9684 KB
1_10.txt AC 124 ms 9680 KB