結果
問題 |
No.505 カードの数式2
|
ユーザー |
|
提出日時 | 2017-04-26 12:54:51 |
言語 | Java (openjdk 23) |
結果 |
RE
|
実行時間 | - |
コード長 | 872 bytes |
コンパイル時間 | 2,252 ms |
コンパイル使用メモリ | 77,080 KB |
実行使用メモリ | 62,100 KB |
最終ジャッジ日時 | 2024-09-13 14:05:00 |
合計ジャッジ時間 | 16,186 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 RE * 9 TLE * 2 -- * 1 |
ソースコード
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]); } } }