結果
問題 | No.281 門松と魔法(1) |
ユーザー | uafr_cs |
提出日時 | 2015-09-18 23:16:22 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,161 bytes |
コンパイル時間 | 2,247 ms |
コンパイル使用メモリ | 77,144 KB |
実行使用メモリ | 47,488 KB |
最終ジャッジ日時 | 2024-04-24 11:35:57 |
合計ジャッジ時間 | 6,229 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 111 ms
46,336 KB |
testcase_01 | AC | 110 ms
41,016 KB |
testcase_02 | AC | 116 ms
41,060 KB |
testcase_03 | AC | 115 ms
41,060 KB |
testcase_04 | AC | 113 ms
41,568 KB |
testcase_05 | AC | 113 ms
41,308 KB |
testcase_06 | AC | 123 ms
41,268 KB |
testcase_07 | AC | 114 ms
41,076 KB |
testcase_08 | AC | 112 ms
41,476 KB |
testcase_09 | AC | 101 ms
40,060 KB |
testcase_10 | AC | 100 ms
40,016 KB |
testcase_11 | AC | 114 ms
41,124 KB |
testcase_12 | AC | 116 ms
41,144 KB |
testcase_13 | AC | 97 ms
39,836 KB |
testcase_14 | AC | 110 ms
41,264 KB |
testcase_15 | TLE | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
testcase_50 | -- | - |
testcase_51 | -- | - |
testcase_52 | -- | - |
testcase_53 | -- | - |
testcase_54 | -- | - |
testcase_55 | -- | - |
testcase_56 | -- | - |
ソースコード
import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; public class Main { public static boolean is_valid_kadomatsu(long h1, long h2, long h3){ if(h1 == h2 || h2 == h3 || h3 == h1){ return false; } if(h1 < h2 && h2 > h3){ return true; }else if(h1 > h2 && h2 < h3){ return true; } return false; } public static int answer = 20; public static void dfs(int count, long d, long h1, long h2, long h3){ if(answer < count){ return; }else if(is_valid_kadomatsu(h1, h2, h3)){ answer = Math.min(answer, count); return; } if(h1 != 0){ dfs(count + 1, d, Math.max(0, h1 - d), h2, h3); } if(h3 != 0){ dfs(count + 1, d, h1, Math.max(0, h2 - d), h3); } if(h3 != 0){ dfs(count + 1, d, h1, h2, Math.max(0, h3 - d)); } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); final long d = sc.nextLong(); final long h1 = sc.nextLong(); final long h2 = sc.nextLong(); final long h3 = sc.nextLong(); dfs(0, d, h1, h2, h3); System.out.println(answer == 20 ? -1 : answer); } }