結果

問題 No.804 野菜が苦手
ユーザー practikovatpractikovat
提出日時 2019-05-22 16:01:53
言語 Java
(openjdk 23)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 929 bytes
コンパイル時間 3,306 ms
コンパイル使用メモリ 74,680 KB
実行使用メモリ 54,268 KB
最終ジャッジ日時 2024-09-17 09:35:09
合計ジャッジ時間 6,892 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class DislikeVegetables {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		// Vegetable の個数
		int a = scan.nextInt();
		// Meat の個数
		int b = scan.nextInt();
		// 一つVegetable を消費するのに必要な倍数
		int c = scan.nextInt();
		// 消費できるMaxの量
		int d = scan.nextInt();

		scan.close();

		// 終了条件
		// 消費できる量はまだあるが、Vegetableがもうない
		// 消費できる量はまだあるが、Meatがもうない
		// Vegetable、Meatはまだあるが、消費できるMaxを超えている

		for(int i = a; i >= 0; i--) {
			
			// 必要なMeatの個数
			int meatNum = i * c;
			
			// 仮の消費量
			int eatNum = (i * c) + i;

			// 消費量が、BよりもDよりも少ない
			if((meatNum <= b) && (eatNum <= d)) {
				System.out.println(i);
				return;
			}
		}

		return;
	}
}
0