結果
問題 | No.505 カードの数式2 |
ユーザー | akitsu818 |
提出日時 | 2017-04-30 18:42:40 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,225 bytes |
コンパイル時間 | 4,708 ms |
コンパイル使用メモリ | 79,424 KB |
実行使用メモリ | 56,596 KB |
最終ジャッジ日時 | 2023-10-11 23:55:20 |
合計ジャッジ時間 | 17,169 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 123 ms
55,980 KB |
testcase_01 | AC | 126 ms
55,792 KB |
testcase_02 | AC | 1,141 ms
56,596 KB |
testcase_03 | AC | 126 ms
55,940 KB |
testcase_04 | AC | 126 ms
55,880 KB |
testcase_05 | AC | 125 ms
55,768 KB |
testcase_06 | AC | 126 ms
55,636 KB |
testcase_07 | AC | 126 ms
55,336 KB |
testcase_08 | AC | 128 ms
55,664 KB |
testcase_09 | AC | 126 ms
55,612 KB |
testcase_10 | AC | 123 ms
55,624 KB |
testcase_11 | AC | 126 ms
55,696 KB |
testcase_12 | AC | 126 ms
55,640 KB |
testcase_13 | AC | 125 ms
55,456 KB |
testcase_14 | AC | 125 ms
55,548 KB |
testcase_15 | AC | 125 ms
55,660 KB |
testcase_16 | AC | 125 ms
55,516 KB |
testcase_17 | AC | 123 ms
55,924 KB |
testcase_18 | AC | 125 ms
55,924 KB |
testcase_19 | AC | 129 ms
56,160 KB |
testcase_20 | AC | 135 ms
55,596 KB |
testcase_21 | AC | 140 ms
55,484 KB |
testcase_22 | AC | 535 ms
55,300 KB |
testcase_23 | AC | 381 ms
55,524 KB |
testcase_24 | AC | 181 ms
55,816 KB |
testcase_25 | AC | 232 ms
55,772 KB |
testcase_26 | AC | 1,077 ms
55,460 KB |
testcase_27 | AC | 377 ms
56,016 KB |
testcase_28 | AC | 1,004 ms
53,960 KB |
testcase_29 | AC | 125 ms
56,116 KB |
testcase_30 | TLE | - |
testcase_31 | -- | - |
ソースコード
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(); long list[] = new long[target]; for(int i=0;i<target;i++){ list[i] = cin.nextLong(); } cin.close(); System.out.println(dfs(1,list[0],list)); } static long dfs(int count,long sum,long array[]){ if(count==target-1){ if(array[count]!=0L){ if(sum<0L){ return Math.max(Math.max(sum*array[count],(long)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]!=0L){ if(sum<0L){ return Math.max(Math.max(dfs(count+1,sum*array[count],array),dfs(count+1,(long)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)); } } } }