結果

問題 No.149 碁石の移動
ユーザー marumaru
提出日時 2016-03-23 20:02:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 576 bytes
コンパイル時間 4,408 ms
コンパイル使用メモリ 71,644 KB
実行使用メモリ 56,368 KB
最終ジャッジ日時 2023-08-25 17:43:29
合計ジャッジ時間 5,676 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
56,368 KB
testcase_01 AC 116 ms
56,344 KB
testcase_02 AC 117 ms
55,800 KB
testcase_03 AC 111 ms
55,916 KB
testcase_04 AC 115 ms
56,100 KB
testcase_05 AC 105 ms
56,300 KB
testcase_06 AC 107 ms
56,120 KB
testcase_07 AC 105 ms
55,988 KB
testcase_08 AC 110 ms
56,180 KB
testcase_09 AC 106 ms
56,104 KB
testcase_10 AC 107 ms
56,292 KB
testcase_11 AC 112 ms
55,892 KB
testcase_12 AC 117 ms
56,016 KB
testcase_13 AC 115 ms
55,800 KB
testcase_14 AC 115 ms
55,676 KB
testcase_15 AC 113 ms
55,612 KB
testcase_16 AC 115 ms
56,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class yukicoder_149 {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int aw = stdIn.nextInt();
		int ab = stdIn.nextInt();
		int bw = stdIn.nextInt();
		int bb = stdIn.nextInt();
		int c = stdIn.nextInt();
		int d = stdIn.nextInt();
		
		if (c <= ab) {
			bb += c;
			ab -= c;
		} else {
			bb += ab;
			bw += c - ab;
			aw -= c - ab;
			ab = 0;
		}
		
		if (d <= bw) {
			aw += d;
			bw -= d;
		} else {
			aw += bw;
			ab += d - bw;
			bb -= d - bw;
			bw = 0;
		}
		
		System.out.println(aw);
	}
}
0