結果

問題 No.286 Modulo Discount Store
ユーザー kou6839kou6839
提出日時 2015-10-16 02:16:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 704 bytes
コンパイル時間 2,470 ms
コンパイル使用メモリ 75,392 KB
実行使用メモリ 55,964 KB
最終ジャッジ日時 2023-09-28 21:59:19
合計ジャッジ時間 10,116 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,596 KB
testcase_01 AC 123 ms
55,500 KB
testcase_02 AC 135 ms
55,576 KB
testcase_03 AC 126 ms
55,560 KB
testcase_04 AC 125 ms
55,808 KB
testcase_05 AC 125 ms
55,640 KB
testcase_06 AC 144 ms
55,596 KB
testcase_07 AC 123 ms
55,624 KB
testcase_08 AC 123 ms
55,608 KB
testcase_09 AC 124 ms
55,576 KB
testcase_10 AC 144 ms
55,344 KB
testcase_11 AC 125 ms
55,584 KB
testcase_12 AC 123 ms
55,716 KB
testcase_13 AC 135 ms
55,652 KB
testcase_14 AC 124 ms
55,572 KB
testcase_15 AC 127 ms
55,504 KB
testcase_16 AC 125 ms
55,552 KB
testcase_17 AC 144 ms
55,828 KB
testcase_18 AC 144 ms
55,284 KB
testcase_19 AC 130 ms
55,596 KB
testcase_20 AC 127 ms
55,724 KB
testcase_21 AC 126 ms
55,532 KB
testcase_22 AC 127 ms
55,432 KB
testcase_23 AC 140 ms
53,672 KB
testcase_24 AC 128 ms
55,820 KB
testcase_25 AC 129 ms
55,964 KB
testcase_26 AC 124 ms
55,552 KB
testcase_27 AC 129 ms
55,928 KB
testcase_28 AC 143 ms
55,812 KB
testcase_29 AC 126 ms
55,488 KB
testcase_30 AC 125 ms
55,628 KB
testcase_31 AC 127 ms
55,580 KB
testcase_32 AC 129 ms
55,656 KB
testcase_33 AC 125 ms
55,340 KB
testcase_34 AC 125 ms
55,636 KB
testcase_35 AC 124 ms
55,580 KB
testcase_36 AC 125 ms
55,296 KB
testcase_37 AC 127 ms
55,720 KB
testcase_38 AC 125 ms
55,540 KB
testcase_39 AC 143 ms
55,644 KB
testcase_40 AC 123 ms
55,596 KB
testcase_41 AC 125 ms
55,928 KB
testcase_42 AC 127 ms
55,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.awt.event.KeyAdapter;
import java.math.BigDecimal;
import java.util.*;

public class Main{
	public static void main(String[] args){
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int[] a = new int[n];
		for(int i=0;i<n;i++) a[i] = sc.nextInt();
		
		int[] dp = new int[1<<n];
		Arrays.fill(dp, 100000000);
		dp[0] = 0;
		for(int i=0;i< (1<<n);i++){
			int now = 0;
			for(int j=0;j<n;j++){
				if(( (1<<j)&i) >0) now+=a[j];
			}
			for(int j=0;j<n;j++){
				if( ( (1<<j)&i) ==0){
					dp[i+(1<<j)]=Math.min(dp[i+(1<<j)], dp[i]+Math.max(a[j]-now%1000,0));
				}
			}
		}
		System.out.println(dp[(1<<n)-1]);
	}	
}
0