結果

問題 No.149 碁石の移動
ユーザー tsunatama5tsunatama5
提出日時 2015-02-17 20:32:42
言語 Java
(openjdk 23)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 870 bytes
コンパイル時間 5,286 ms
コンパイル使用メモリ 77,248 KB
実行使用メモリ 41,424 KB
最終ジャッジ日時 2024-12-24 02:53:07
合計ジャッジ時間 6,067 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

package P149;

import java.util.Scanner;

public class P149 {
	
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String x = sc.nextLine();
		String[] xstrs = x.split(" ",0);
		int Aw = Integer.parseInt(xstrs[0]);
		int Ab = Integer.parseInt(xstrs[1]);		
		
		String y = sc.nextLine();
		String[] ystrs = y.split(" ",0);
		int Bw = Integer.parseInt(ystrs[0]);
		int Bb = Integer.parseInt(ystrs[1]);		
		
		String z = sc.nextLine();
		String[] zstrs = z.split(" ",0);
		int C = Integer.parseInt(zstrs[0]);
		int D = Integer.parseInt(zstrs[1]);
		
		int Ans = 0;
		
		if (C <= Ab) {
			if (D <= Bw) {
				Ans = Aw + D;
			} else if (D > Bw) {
				Ans = Aw + Bw;
			}
		} else if (C > Ab) {
			if (D <= Bw+C-Ab) {
				Ans = Aw - (C - Ab) + D;
			} else if (D > Bw+C-Ab) {
				Ans = Aw + Bw;
			}
		}
		
				
		System.out.println(Ans);
	}
}
0