結果

問題 No.149 碁石の移動
ユーザー maru
提出日時 2016-03-23 20:02:42
言語 Java
(openjdk 23)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 576 bytes
コンパイル時間 3,191 ms
コンパイル使用メモリ 74,356 KB
実行使用メモリ 41,468 KB
最終ジャッジ日時 2024-12-24 03:16:04
合計ジャッジ時間 5,981 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

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