結果

問題 No.804 野菜が苦手
ユーザー practikovatpractikovat
提出日時 2019-05-22 15:48:14
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 885 bytes
コンパイル時間 2,977 ms
コンパイル使用メモリ 74,612 KB
実行使用メモリ 54,240 KB
最終ジャッジ日時 2024-09-17 09:33:34
合計ジャッジ時間 5,905 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16 WA * 2
権限があれば一括ダウンロードができます

ソースコード

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--) {
			// 仮の消費量
			int eatNum = i * c;

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

		System.out.println(0);
		return;
	}
}
0