提出 #39158940


ソースコード 拡げる

use proconio::input;

fn main() {
    input! {
        x: i64,
        y: i64,
    };

    let mut min = 1_i64 << 60;
    for &b1 in &[false, true] {
        for &b2 in &[false, true] {
            let mut a = x;
            let mut b = y;
            let mut count = 0;
            if b1 {
                a *= -1;
                count += 1;
            }
            if b2 {
                b *= -1;
                count += 1;
            }
            if a <= b {
                min = min.min(b - a + count);
            }
        }
    }

    println!("{}", min);
}

提出情報

提出日時
問題 A - Simple Calculator
ユーザ bouzuya
言語 Rust (1.42.0)
得点 300
コード長 573 Byte
結果 AC
実行時間 7 ms
メモリ 2112 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 14
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
0_00.txt AC 7 ms 1944 KiB
0_01.txt AC 3 ms 1888 KiB
0_02.txt AC 4 ms 2032 KiB
1_00.txt AC 2 ms 2012 KiB
1_01.txt AC 1 ms 2024 KiB
1_02.txt AC 2 ms 1944 KiB
1_03.txt AC 2 ms 2004 KiB
1_04.txt AC 1 ms 1992 KiB
1_05.txt AC 1 ms 2036 KiB
1_06.txt AC 2 ms 2040 KiB
1_07.txt AC 1 ms 2112 KiB
1_08.txt AC 1 ms 2100 KiB
1_09.txt AC 1 ms 2012 KiB
1_10.txt AC 2 ms 2112 KiB