結果
| 問題 |
No.505 カードの数式2
|
| コンテスト | |
| ユーザー |
akitsu818
|
| 提出日時 | 2017-04-30 18:15:11 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 648 bytes |
| コンパイル時間 | 2,355 ms |
| コンパイル使用メモリ | 74,636 KB |
| 実行使用メモリ | 54,436 KB |
| 最終ジャッジ日時 | 2024-09-13 23:53:12 |
| 合計ジャッジ時間 | 8,056 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 8 |
ソースコード
import java.util.Scanner;
public class Main {
static int target;
public static void main(String argas[]){
Scanner cin = new Scanner(System.in);
target = cin.nextInt();
int list[] = new int[target];
for(int i=0;i<target;i++){
list[i] = cin.nextInt();
}
cin.close();
System.out.println(dfs(1,list[0],list));
}
static int dfs(int count,int sum,int array[]){
if(count==target-1){
return Math.max(sum*array[count], Math.max(sum+array[count],sum-array[count]));
}else{
return Math.max(dfs(count+1,sum*array[count],array), Math.max(dfs(count+1,sum+array[count],array), dfs(count+1,sum-array[count],array)));
}
}
}
akitsu818