結果
問題 |
No.505 カードの数式2
|
ユーザー |
![]() |
提出日時 | 2017-04-21 23:24:37 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 750 bytes |
コンパイル時間 | 1,806 ms |
コンパイル使用メモリ | 76,860 KB |
実行使用メモリ | 47,208 KB |
最終ジャッジ日時 | 2024-07-20 17:45:14 |
合計ジャッジ時間 | 5,644 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 TLE * 1 |
other | -- * 29 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int [] A = new int [N]; for(int i=0; i<N; i++){ A[i] = sc.nextInt(); } solve(N,A); } static int ans; static void solve(int N, int[]A){ ans = Integer.MIN_VALUE; funtion(N,A,1,A[0]); System.out.println(ans); } static void funtion(int N, int[]A, int k, int X){ if(N==k){ ans=Math.max(ans,X); }else{ funtion(N,A,k+1,X+A[k]); funtion(N,A,k+1,X-A[k]); funtion(N,A,k+1,X*A[k]); if(A[k]!=0)funtion(N,A,k+1,X/A[k]); } } }