結果

問題 No.27 板の準備
ユーザー kou6839kou6839
提出日時 2014-12-10 13:44:56
言語 Java21
(openjdk 21)
結果
AC  
実行時間 130 ms / 5,000 ms
コード長 935 bytes
コンパイル時間 2,002 ms
コンパイル使用メモリ 74,156 KB
実行使用メモリ 56,192 KB
最終ジャッジ日時 2023-08-27 03:24:41
合計ジャッジ時間 5,363 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
56,192 KB
testcase_01 AC 130 ms
55,772 KB
testcase_02 AC 129 ms
55,832 KB
testcase_03 AC 129 ms
55,980 KB
testcase_04 AC 130 ms
55,960 KB
testcase_05 AC 130 ms
55,564 KB
testcase_06 AC 130 ms
56,140 KB
testcase_07 AC 129 ms
55,844 KB
testcase_08 AC 129 ms
55,824 KB
testcase_09 AC 129 ms
55,900 KB
testcase_10 AC 130 ms
55,712 KB
testcase_11 AC 128 ms
55,552 KB
testcase_12 AC 129 ms
56,140 KB
testcase_13 AC 128 ms
55,508 KB
testcase_14 AC 128 ms
55,548 KB
testcase_15 AC 129 ms
55,800 KB
testcase_16 AC 128 ms
55,924 KB
testcase_17 AC 129 ms
55,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.*;
import java.util.*;
 
public class Main {
	static int check(int a,int b,int c,int ita){
		int res=100000;
		for(int i=ita/c;i>=0;i--){
			for(int j=(ita-c*i)/b;j>=0;j--){
				if( (ita-c*i-b*j)%a==0){
					res=Math.min(res,i+j+(ita-c*i-b*j)/a);
				}else{
					continue;
				}	
			}
		}
		return res;
	}
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] v = new int[4];
        for(int i=0;i<4;i++){
        	v[i]=sc.nextInt();
        }
        int ans=Integer.MAX_VALUE;
        for(int i=1;i<=28;i++){
        	for(int j=i+1;j<=29;j++){
        		f: for(int k=j+1;k<=30;k++){
        			int count=0;
        			for(int l=0;l<4;l++){
        				int temp=v[l];
        				count+=check(i,j,k,temp);
        			}
    				ans=Math.min(ans, count);
        		}
        	}
        }
        System.out.println(ans);
    }
}			
0