結果

問題 No.149 碁石の移動
ユーザー Tsukasa_Type
提出日時 2018-03-01 23:24:04
言語 Java
(openjdk 23)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 819 bytes
コンパイル時間 2,196 ms
コンパイル使用メモリ 77,336 KB
実行使用メモリ 41,532 KB
最終ジャッジ日時 2024-12-26 01:20:19
合計ジャッジ時間 5,339 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

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