結果

問題 No.149 碁石の移動
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-03-01 23:24:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 819 bytes
コンパイル時間 2,027 ms
コンパイル使用メモリ 73,980 KB
実行使用メモリ 56,696 KB
最終ジャッジ日時 2023-08-26 22:15:27
合計ジャッジ時間 5,132 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
56,396 KB
testcase_01 AC 115 ms
56,224 KB
testcase_02 AC 120 ms
56,244 KB
testcase_03 AC 117 ms
56,032 KB
testcase_04 AC 122 ms
56,184 KB
testcase_05 AC 120 ms
55,900 KB
testcase_06 AC 119 ms
55,952 KB
testcase_07 AC 123 ms
55,920 KB
testcase_08 AC 122 ms
55,484 KB
testcase_09 AC 121 ms
56,696 KB
testcase_10 AC 122 ms
55,768 KB
testcase_11 AC 120 ms
56,000 KB
testcase_12 AC 122 ms
56,064 KB
testcase_13 AC 122 ms
55,808 KB
testcase_14 AC 118 ms
56,332 KB
testcase_15 AC 119 ms
55,652 KB
testcase_16 AC 120 ms
56,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		//入力
		Box A = new Box(sc.nextInt(),sc.nextInt());
		Box B = new Box(sc.nextInt(),sc.nextInt());
		int c = sc.nextInt();
		int d = sc.nextInt();
		
		//動作1
		if (c > A.black) {
			B.white += c - A.black;
			A.white -= c - A.black;
			B.black += A.black;
			A.black = 0;
			
		}
		else {
			B.black += c;
			A.black -= c;
		}
		
		//動作2
		if (d > B.white) {
			A.black += d - B.white;
			B.black -= d - B.white;
			A.white += B.white;
			B.white = 0;
		}
		else {
			A.white += d;
			B.white -= d;
		}
		
		//出力
		out.println(A.white);
	}
}

class Box {
	int white;
	int black;
	Box (int a, int b) {
		this.white = a;
		this.black = b;
	}
}
0