結果
問題 | No.505 カードの数式2 |
ユーザー | akitsu818 |
提出日時 | 2017-04-30 18:15:11 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 648 bytes |
コンパイル時間 | 2,144 ms |
コンパイル使用メモリ | 71,772 KB |
実行使用メモリ | 57,968 KB |
最終ジャッジ日時 | 2023-10-11 23:52:53 |
合計ジャッジ時間 | 8,180 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 125 ms
55,768 KB |
testcase_01 | AC | 123 ms
55,724 KB |
testcase_02 | AC | 150 ms
55,500 KB |
testcase_03 | AC | 126 ms
55,612 KB |
testcase_04 | AC | 128 ms
55,676 KB |
testcase_05 | AC | 121 ms
55,592 KB |
testcase_06 | AC | 124 ms
55,580 KB |
testcase_07 | AC | 125 ms
55,812 KB |
testcase_08 | AC | 122 ms
55,544 KB |
testcase_09 | AC | 123 ms
55,616 KB |
testcase_10 | AC | 123 ms
55,504 KB |
testcase_11 | WA | - |
testcase_12 | AC | 125 ms
55,536 KB |
testcase_13 | AC | 126 ms
55,564 KB |
testcase_14 | AC | 125 ms
55,808 KB |
testcase_15 | AC | 127 ms
55,724 KB |
testcase_16 | AC | 125 ms
55,532 KB |
testcase_17 | WA | - |
testcase_18 | AC | 126 ms
55,868 KB |
testcase_19 | AC | 123 ms
55,300 KB |
testcase_20 | AC | 133 ms
55,736 KB |
testcase_21 | AC | 155 ms
55,648 KB |
testcase_22 | WA | - |
testcase_23 | AC | 155 ms
55,864 KB |
testcase_24 | AC | 154 ms
55,592 KB |
testcase_25 | AC | 152 ms
55,772 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 151 ms
55,724 KB |
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){ return Math.max(sum*array[count], Math.max(sum+array[count],sum-array[count])); }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))); } } }