結果
| 問題 |
No.505 カードの数式2
|
| コンテスト | |
| ユーザー |
kohaku_kohaku
|
| 提出日時 | 2017-04-21 23:01:19 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 686 bytes |
| コンパイル時間 | 2,208 ms |
| コンパイル使用メモリ | 73,884 KB |
| 実行使用メモリ | 41,444 KB |
| 最終ジャッジ日時 | 2024-07-20 06:34:29 |
| 合計ジャッジ時間 | 8,318 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 WA * 9 |
ソースコード
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 = 0;
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]);
}
}
}
kohaku_kohaku