結果
問題 | No.1083 余りの余り |
ユーザー | tenten |
提出日時 | 2020-08-18 18:15:38 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,145 bytes |
コンパイル時間 | 2,201 ms |
コンパイル使用メモリ | 77,548 KB |
実行使用メモリ | 142,300 KB |
最終ジャッジ日時 | 2024-04-20 07:48:09 |
合計ジャッジ時間 | 13,867 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 135 ms
46,712 KB |
testcase_01 | AC | 140 ms
41,136 KB |
testcase_02 | AC | 140 ms
41,500 KB |
testcase_03 | AC | 139 ms
41,432 KB |
testcase_04 | AC | 149 ms
41,232 KB |
testcase_05 | AC | 838 ms
62,268 KB |
testcase_06 | AC | 140 ms
41,376 KB |
testcase_07 | AC | 150 ms
41,324 KB |
testcase_08 | AC | 139 ms
41,596 KB |
testcase_09 | AC | 140 ms
41,312 KB |
testcase_10 | AC | 141 ms
41,360 KB |
testcase_11 | AC | 135 ms
40,684 KB |
testcase_12 | AC | 125 ms
40,228 KB |
testcase_13 | AC | 136 ms
41,468 KB |
testcase_14 | AC | 137 ms
41,356 KB |
testcase_15 | AC | 139 ms
41,264 KB |
testcase_16 | AC | 138 ms
41,300 KB |
testcase_17 | AC | 139 ms
41,116 KB |
testcase_18 | AC | 1,928 ms
91,132 KB |
testcase_19 | AC | 838 ms
62,232 KB |
testcase_20 | AC | 150 ms
41,608 KB |
testcase_21 | AC | 185 ms
43,204 KB |
testcase_22 | AC | 138 ms
41,168 KB |
testcase_23 | TLE | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
ソースコード
import java.util.*; public class Main { static final int MOD = 1000000007; static int n; static int k; static int[] arr; static int[][] dp; public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); k = sc.nextInt(); arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = sc.nextInt(); } dp = new int[n][1 << n]; int max = 0; for (int i = 0; i < n; i++) { max = Math.max(max, dfw(i, (1 << n) - 1)); } System.out.println(max); } static int dfw(int idx, int mask) { if (dp[idx][mask] == 0) { int next = (mask ^ (1 << idx)); if (next == 0) { dp[idx][mask] = k % arr[idx]; } else { for (int i = 0; i < n; i++) { if ((next & (1 << i)) == 0) { continue; } dp[idx][mask] = Math.max(dp[idx][mask], dfw(i, next) % arr[idx]); } } } return dp[idx][mask]; } }