結果
問題 | No.505 カードの数式2 |
ユーザー | atkrym1217 |
提出日時 | 2017-04-26 12:54:51 |
言語 | Java21 (openjdk 21) |
結果 |
RE
|
実行時間 | - |
コード長 | 872 bytes |
コンパイル時間 | 2,024 ms |
コンパイル使用メモリ | 74,252 KB |
実行使用メモリ | 59,812 KB |
最終ジャッジ日時 | 2023-10-11 15:15:10 |
合計ジャッジ時間 | 16,527 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 123 ms
59,812 KB |
testcase_01 | AC | 125 ms
55,820 KB |
testcase_02 | AC | 1,865 ms
56,188 KB |
testcase_03 | AC | 124 ms
55,944 KB |
testcase_04 | AC | 124 ms
56,044 KB |
testcase_05 | AC | 123 ms
56,012 KB |
testcase_06 | AC | 122 ms
56,052 KB |
testcase_07 | AC | 125 ms
56,056 KB |
testcase_08 | AC | 124 ms
56,028 KB |
testcase_09 | RE | - |
testcase_10 | AC | 124 ms
55,816 KB |
testcase_11 | AC | 124 ms
55,700 KB |
testcase_12 | AC | 125 ms
56,116 KB |
testcase_13 | RE | - |
testcase_14 | AC | 126 ms
55,688 KB |
testcase_15 | AC | 124 ms
55,672 KB |
testcase_16 | RE | - |
testcase_17 | AC | 126 ms
56,308 KB |
testcase_18 | AC | 126 ms
55,884 KB |
testcase_19 | RE | - |
testcase_20 | AC | 139 ms
56,420 KB |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | TLE | - |
testcase_27 | AC | 750 ms
56,108 KB |
testcase_28 | TLE | - |
testcase_29 | AC | 123 ms
55,928 KB |
testcase_30 | TLE | - |
testcase_31 | -- | - |
ソースコード
import java.util.*; public class Main { public static Scanner sc = new Scanner(System.in); public static int n; public static int[] a; public static int[] b; public static long ret = Long.MIN_VALUE; public static void main(String[] args) throws Exception { n = sc.nextInt(); a = new int[n]; b = new int[n]; for (int i = 0;i < n;i++) a[i] = sc.nextInt(); calc(0, a[0]); System.out.println(ret); } public static void calc(int c, long val) { if (c==n-1) { ret = Math.max(ret,val); return; } int t = val>=0?3:4; for (int i = 0;i < t;i++) { if (i==0) calc(c+1,val+a[c+1]); if (i==1) calc(c+1,val-a[c+1]); if (i==2) calc(c+1,val*a[c+1]); if (i==3) calc(c+1,val/a[c+1]); } } }