結果

問題 No.505 カードの数式2
ユーザー yagi2yagi2
提出日時 2017-04-27 17:09:53
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,302 bytes
コンパイル時間 2,653 ms
コンパイル使用メモリ 74,912 KB
実行使用メモリ 57,988 KB
最終ジャッジ日時 2023-10-11 16:06:13
合計ジャッジ時間 8,013 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,844 KB
testcase_01 AC 119 ms
55,764 KB
testcase_02 AC 120 ms
55,924 KB
testcase_03 AC 119 ms
56,192 KB
testcase_04 AC 118 ms
55,620 KB
testcase_05 AC 120 ms
55,612 KB
testcase_06 AC 119 ms
55,632 KB
testcase_07 AC 119 ms
55,668 KB
testcase_08 AC 120 ms
55,320 KB
testcase_09 AC 119 ms
55,648 KB
testcase_10 AC 119 ms
55,440 KB
testcase_11 AC 119 ms
56,112 KB
testcase_12 AC 120 ms
55,300 KB
testcase_13 WA -
testcase_14 AC 117 ms
53,652 KB
testcase_15 WA -
testcase_16 AC 119 ms
55,788 KB
testcase_17 AC 119 ms
55,804 KB
testcase_18 AC 120 ms
55,740 KB
testcase_19 WA -
testcase_20 AC 121 ms
55,816 KB
testcase_21 AC 120 ms
55,704 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 123 ms
55,736 KB
testcase_30 AC 119 ms
55,340 KB
testcase_31 AC 120 ms
55,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder.No505;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        List<Integer> nums = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            nums.add(Integer.parseInt(sc.next()));
        }

        long max = nums.get(0);
        long min = nums.get(0);
        for (int i = 1; i < N; i++) {
            long tmax = Long.MIN_VALUE;
            long tmin = Long.MAX_VALUE;

            tmax = Math.max(tmax, max + nums.get(i));
            tmin = Math.min(tmin, min + nums.get(i));

            tmax = Math.max(tmax, max - nums.get(i));
            tmin = Math.min(tmin, min - nums.get(i));

            tmax = Math.max(tmax, max * nums.get(i));
            tmin = Math.min(tmin, min * nums.get(i));

            if (nums.get(i) != 0) {
                tmax = Math.max(tmax, max / nums.get(i));
                tmax = Math.max(tmax, min / nums.get(i));

                tmin = Math.min(tmin, max / nums.get(i));
                tmin = Math.min(tmin, min / nums.get(i));
            }

            min = tmin;
            max = tmax;
        }
        System.out.println(max);
    }
}
0