結果
問題 | No.505 カードの数式2 |
ユーザー | akitsu818 |
提出日時 | 2017-04-30 18:25:37 |
言語 | Java19 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,214 bytes |
コンパイル時間 | 2,234 ms |
コンパイル使用メモリ | 73,984 KB |
実行使用メモリ | 56,324 KB |
最終ジャッジ日時 | 2023-10-11 23:53:49 |
合計ジャッジ時間 | 12,588 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 124 ms
56,152 KB |
testcase_01 | AC | 125 ms
55,740 KB |
testcase_02 | AC | 509 ms
56,060 KB |
testcase_03 | AC | 125 ms
55,976 KB |
testcase_04 | AC | 125 ms
55,960 KB |
testcase_05 | AC | 125 ms
55,744 KB |
testcase_06 | AC | 126 ms
55,732 KB |
testcase_07 | AC | 125 ms
55,944 KB |
testcase_08 | AC | 125 ms
55,952 KB |
testcase_09 | AC | 123 ms
55,824 KB |
testcase_10 | AC | 124 ms
55,400 KB |
testcase_11 | AC | 125 ms
55,872 KB |
testcase_12 | AC | 130 ms
55,684 KB |
testcase_13 | AC | 125 ms
55,960 KB |
testcase_14 | AC | 126 ms
55,812 KB |
testcase_15 | AC | 124 ms
56,172 KB |
testcase_16 | AC | 124 ms
55,892 KB |
testcase_17 | AC | 124 ms
55,688 KB |
testcase_18 | AC | 125 ms
56,000 KB |
testcase_19 | AC | 128 ms
56,036 KB |
testcase_20 | AC | 129 ms
55,780 KB |
testcase_21 | AC | 139 ms
55,596 KB |
testcase_22 | WA | - |
testcase_23 | AC | 279 ms
55,820 KB |
testcase_24 | AC | 159 ms
55,808 KB |
testcase_25 | AC | 190 ms
55,684 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 126 ms
55,944 KB |
testcase_30 | TLE | - |
testcase_31 | WA | - |
ソースコード
import java.util.Scanner; public class Main { static int target; public static void main(String argas[]){ Scanner cin = new Scanner(System.in); target = cin.nextInt(); int list[] = new int[target]; for(int i=0;i<target;i++){ list[i] = cin.nextInt(); } cin.close(); System.out.println(dfs(1,list[0],list)); } static int dfs(int count,int sum,int array[]){ if(count==target-1){ if(array[count]!=0){ if(sum<0){ return Math.max(Math.max(sum*array[count],(int)sum/array[count]), Math.max(sum+array[count],sum-array[count])); }else{ return Math.max(sum*array[count], Math.max(sum+array[count],sum-array[count])); } }else{ return Math.max(0, sum+array[count]); } }else{ if(array[count]!=0){ if(sum<0){ return Math.max(Math.max(dfs(count+1,sum*array[count],array),dfs(count+1,(int)sum/array[count],array)), Math.max(dfs(count+1,sum+array[count],array), dfs(count+1,sum-array[count],array))); }else{ return Math.max(dfs(count+1,sum*array[count],array), Math.max(dfs(count+1,sum+array[count],array), dfs(count+1,sum-array[count],array))); } }else{ return Math.max(dfs(count+1,0,array), dfs(count+1,sum,array)); } } } }