結果
問題 | No.505 カードの数式2 |
ユーザー | akitsu818 |
提出日時 | 2017-04-30 18:21:10 |
言語 | Java19 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 915 bytes |
コンパイル時間 | 2,629 ms |
コンパイル使用メモリ | 74,008 KB |
実行使用メモリ | 57,620 KB |
最終ジャッジ日時 | 2023-10-11 23:53:28 |
合計ジャッジ時間 | 20,702 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 124 ms
55,644 KB |
testcase_01 | AC | 130 ms
55,536 KB |
testcase_02 | TLE | - |
testcase_03 | AC | 125 ms
55,840 KB |
testcase_04 | AC | 124 ms
55,656 KB |
testcase_05 | AC | 126 ms
55,312 KB |
testcase_06 | AC | 126 ms
55,908 KB |
testcase_07 | AC | 126 ms
55,868 KB |
testcase_08 | AC | 125 ms
55,732 KB |
testcase_09 | AC | 124 ms
55,528 KB |
testcase_10 | AC | 124 ms
55,528 KB |
testcase_11 | AC | 126 ms
55,528 KB |
testcase_12 | AC | 125 ms
55,344 KB |
testcase_13 | AC | 127 ms
55,300 KB |
testcase_14 | AC | 126 ms
55,572 KB |
testcase_15 | AC | 125 ms
56,004 KB |
testcase_16 | AC | 126 ms
55,956 KB |
testcase_17 | WA | - |
testcase_18 | AC | 127 ms
54,032 KB |
testcase_19 | AC | 128 ms
55,616 KB |
testcase_20 | AC | 130 ms
55,868 KB |
testcase_21 | AC | 173 ms
55,760 KB |
testcase_22 | WA | - |
testcase_23 | AC | 783 ms
55,952 KB |
testcase_24 | AC | 293 ms
56,220 KB |
testcase_25 | AC | 457 ms
54,172 KB |
testcase_26 | TLE | - |
testcase_27 | TLE | - |
testcase_28 | TLE | - |
testcase_29 | AC | 127 ms
57,620 KB |
testcase_30 | TLE | - |
testcase_31 | TLE | - |
ソースコード
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){ return Math.max(Math.max(sum*array[count],(int)sum/array[count]), Math.max(sum+array[count],sum-array[count])); }else{ return Math.max(0, sum+array[count]); } }else{ if(array[count]!=0){ return Math.max(Math.max(dfs(count+1,sum*array[count],array),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)); } } } }