結果

問題 No.149 碁石の移動
ユーザー YamaKasa
提出日時 2018-05-17 21:46:08
言語 Java
(openjdk 23)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 2,061 ms
コンパイル使用メモリ 74,020 KB
実行使用メモリ 41,376 KB
最終ジャッジ日時 2024-06-28 13:34:25
合計ジャッジ時間 5,089 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int Aw = scan.nextInt();
		int Ab = scan.nextInt();
		int Bw = scan.nextInt();
		int Bb = scan.nextInt();
		int C = scan.nextInt();
		int D = scan.nextInt();
		scan.close();
		if(C >= Ab) {
			int w = C - Ab;
			int b = Ab;
			Aw = Aw - w;
			Bw = Bw + w;
			Bb = Bb + b;
			if(D <= Bw) {
				Aw = Aw + D;
			}else {
				Aw = Aw + Bw;
			}
		}else {
			int b = C;
			Bb = Bb + b;
			if(D <= Bw) {
				Aw = Aw + D;
			}else {
				Aw = Aw + Bw;
			}
		}
		System.out.println(Aw);
	}
}
0