結果

問題 No.804 野菜が苦手
ユーザー practikovatpractikovat
提出日時 2019-05-22 15:42:22
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 869 bytes
コンパイル時間 3,266 ms
コンパイル使用メモリ 76,888 KB
実行使用メモリ 57,648 KB
最終ジャッジ日時 2023-10-17 11:15:08
合計ジャッジ時間 7,171 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
57,500 KB
testcase_01 AC 127 ms
55,552 KB
testcase_02 WA -
testcase_03 AC 128 ms
57,480 KB
testcase_04 AC 128 ms
57,396 KB
testcase_05 AC 128 ms
57,648 KB
testcase_06 AC 127 ms
57,396 KB
testcase_07 AC 125 ms
57,552 KB
testcase_08 WA -
testcase_09 AC 127 ms
57,540 KB
testcase_10 AC 128 ms
57,520 KB
testcase_11 AC 128 ms
57,520 KB
testcase_12 AC 126 ms
57,144 KB
testcase_13 AC 125 ms
57,188 KB
testcase_14 AC 131 ms
57,536 KB
testcase_15 AC 129 ms
57,488 KB
testcase_16 AC 128 ms
57,564 KB
testcase_17 AC 128 ms
57,648 KB
testcase_18 AC 126 ms
57,420 KB
testcase_19 AC 128 ms
57,520 KB
権限があれば一括ダウンロードができます

ソースコード

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();

		// 終了条件
		// 消費できる量はまだあるが、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