結果

問題 No.32 貯金箱の憂鬱
ユーザー scachescache
提出日時 2014-10-01 00:04:58
言語 Java19
(openjdk 21)
結果
AC  
実行時間 2,816 ms / 5,000 ms
コード長 1,017 bytes
コンパイル時間 2,169 ms
コンパイル使用メモリ 73,784 KB
実行使用メモリ 56,212 KB
最終ジャッジ日時 2023-09-30 07:45:06
合計ジャッジ時間 39,187 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,791 ms
55,736 KB
testcase_01 AC 2,795 ms
55,864 KB
testcase_02 AC 2,816 ms
55,708 KB
testcase_03 AC 2,789 ms
55,852 KB
testcase_04 AC 2,790 ms
55,736 KB
testcase_05 AC 2,790 ms
55,640 KB
testcase_06 AC 2,794 ms
55,504 KB
testcase_07 AC 2,791 ms
55,816 KB
testcase_08 AC 2,793 ms
55,672 KB
testcase_09 AC 2,793 ms
55,716 KB
testcase_10 AC 2,793 ms
55,832 KB
testcase_11 AC 2,791 ms
56,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
//		long s = System.currentTimeMillis();
		Main p = new Main();
//		long e = System.currentTimeMillis();
//		System.out.println((e-s)/1000.0);
	}

	public Main() {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int m = sc.nextInt();
		int n = sc.nextInt();
		solve(l, m, n);
	}

	public void solve(int l, int m, int n) {
		final int MAX = 100*1000+25*1000+1*1000;
		int[] dp = new int[MAX+1];
		Arrays.fill(dp, 1000000);
		int y = 0;
		int hy = 0;
		int ty = 0;
		int oy = 0;
		for(int i=0;i<=1000;i++){
			ty = hy;
			for(int j=0;j<=1000;j++){
				oy = ty;
				for(int k=0;k<=1000;k++){
//					dp[oy] = Math.min(dp[oy], i+j+k);
					dp[oy] = dp[oy] > i+j+k ? i+j+k : dp[oy];
					oy += 1;
				}
				
				ty+= 25;
			}
			hy+= 100;
			
		}
		
		int res = 1000000;
		for(int i=(l*100+m*25+n)%1000; i<=MAX;i+=1000 )
			res =Math.min(res, dp[i]);
		
		
		System.out.println(res);
	}

}
0