結果

問題 No.505 カードの数式2
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2017-04-21 23:01:19
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 686 bytes
コンパイル時間 1,673 ms
コンパイル使用メモリ 71,460 KB
実行使用メモリ 56,364 KB
最終ジャッジ日時 2023-09-27 12:27:30
合計ジャッジ時間 6,751 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
56,220 KB
testcase_01 AC 103 ms
55,860 KB
testcase_02 AC 155 ms
55,900 KB
testcase_03 AC 105 ms
55,956 KB
testcase_04 AC 104 ms
55,768 KB
testcase_05 AC 106 ms
55,668 KB
testcase_06 AC 104 ms
55,940 KB
testcase_07 AC 107 ms
56,188 KB
testcase_08 AC 105 ms
55,760 KB
testcase_09 AC 103 ms
56,004 KB
testcase_10 AC 99 ms
55,620 KB
testcase_11 WA -
testcase_12 AC 103 ms
56,124 KB
testcase_13 AC 108 ms
55,808 KB
testcase_14 WA -
testcase_15 AC 106 ms
56,056 KB
testcase_16 AC 108 ms
55,692 KB
testcase_17 WA -
testcase_18 AC 108 ms
55,780 KB
testcase_19 AC 102 ms
54,360 KB
testcase_20 AC 108 ms
55,772 KB
testcase_21 AC 159 ms
56,080 KB
testcase_22 WA -
testcase_23 AC 156 ms
55,460 KB
testcase_24 AC 162 ms
55,948 KB
testcase_25 AC 156 ms
56,120 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 158 ms
55,708 KB
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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]);
        }
    }
}
0