結果
問題 | No.505 カードの数式2 |
ユーザー |
|
提出日時 | 2017-04-26 12:49:35 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 800 bytes |
コンパイル時間 | 2,172 ms |
コンパイル使用メモリ | 74,436 KB |
実行使用メモリ | 54,420 KB |
最終ジャッジ日時 | 2024-09-13 14:04:09 |
合計ジャッジ時間 | 8,949 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 WA * 3 |
ソースコード
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; } for (int i = 0;i < 3;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]); } } }