結果

問題 No.505 カードの数式2
ユーザー htensaihtensai
提出日時 2019-12-26 11:50:29
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 733 bytes
コンパイル時間 2,311 ms
コンパイル使用メモリ 75,788 KB
実行使用メモリ 54,528 KB
最終ジャッジ日時 2024-04-14 09:20:29
合計ジャッジ時間 8,357 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
53,840 KB
testcase_01 AC 139 ms
54,104 KB
testcase_02 AC 176 ms
53,836 KB
testcase_03 AC 146 ms
54,076 KB
testcase_04 AC 141 ms
54,096 KB
testcase_05 AC 138 ms
54,180 KB
testcase_06 AC 145 ms
54,108 KB
testcase_07 AC 138 ms
54,192 KB
testcase_08 AC 139 ms
54,092 KB
testcase_09 AC 139 ms
54,084 KB
testcase_10 AC 140 ms
54,224 KB
testcase_11 WA -
testcase_12 AC 137 ms
54,204 KB
testcase_13 WA -
testcase_14 AC 137 ms
53,852 KB
testcase_15 WA -
testcase_16 AC 139 ms
53,968 KB
testcase_17 WA -
testcase_18 AC 137 ms
53,828 KB
testcase_19 WA -
testcase_20 AC 139 ms
53,872 KB
testcase_21 AC 138 ms
53,840 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 137 ms
54,060 KB
testcase_31 AC 136 ms
54,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long max = sc.nextInt();
        long min = max;
        for (int i = 1; i < n; i++) {
            long tmax = Long.MIN_VALUE;
            long tmin = Long.MAX_VALUE;
            long x = sc.nextInt();
            tmax = Math.max(tmax, max + x);
            tmax = Math.max(tmax, max - x);
            tmax = Math.max(tmax, max * x);
            tmin = Math.max(tmin, max + x);
            tmin = Math.max(tmin, max - x);
            tmin = Math.max(tmin, max * x);
            max = tmax;
            min = tmin;
        }
        System.out.println(max);
    }
}
0