結果

問題 No.505 カードの数式2
ユーザー uafr_csuafr_cs
提出日時 2017-10-30 18:02:09
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,183 bytes
コンパイル時間 1,873 ms
コンパイル使用メモリ 77,160 KB
実行使用メモリ 41,332 KB
最終ジャッジ日時 2024-05-02 01:27:36
合計ジャッジ時間 6,416 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
41,148 KB
testcase_01 AC 107 ms
40,832 KB
testcase_02 AC 109 ms
41,172 KB
testcase_03 AC 110 ms
41,136 KB
testcase_04 AC 105 ms
39,788 KB
testcase_05 AC 109 ms
41,040 KB
testcase_06 AC 105 ms
40,984 KB
testcase_07 AC 104 ms
40,468 KB
testcase_08 AC 95 ms
39,800 KB
testcase_09 AC 100 ms
40,300 KB
testcase_10 AC 98 ms
39,948 KB
testcase_11 WA -
testcase_12 AC 99 ms
39,836 KB
testcase_13 AC 106 ms
40,824 KB
testcase_14 AC 105 ms
40,848 KB
testcase_15 AC 105 ms
41,072 KB
testcase_16 AC 99 ms
40,388 KB
testcase_17 WA -
testcase_18 AC 101 ms
40,000 KB
testcase_19 AC 114 ms
40,956 KB
testcase_20 AC 114 ms
41,164 KB
testcase_21 AC 114 ms
41,048 KB
testcase_22 AC 114 ms
40,692 KB
testcase_23 AC 109 ms
41,228 KB
testcase_24 AC 110 ms
41,144 KB
testcase_25 AC 101 ms
39,896 KB
testcase_26 AC 109 ms
40,948 KB
testcase_27 AC 109 ms
41,180 KB
testcase_28 AC 99 ms
40,168 KB
testcase_29 WA -
testcase_30 AC 101 ms
40,056 KB
testcase_31 AC 97 ms
40,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static long MOD = 1000000007;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		long[] as = new long[N];
		for(int i = 0; i < N; i++){ as[i] = sc.nextLong(); }
		
		long min = as[0], max = as[0];
		for(int i = 1; i < N; i++){
			long curr_min = min + as[i];
			long curr_max = max + as[i];
			
			// +
			{
				curr_min = Math.min(curr_min, min + as[i]);
				curr_min = Math.min(curr_min, max + as[i]);
				curr_max = Math.max(curr_max, min + as[i]);
				curr_max = Math.max(curr_max, max + as[i]);
			}
			// -
			{
				curr_min = Math.min(curr_min, min - as[i]);
				curr_min = Math.min(curr_min, max - as[i]);
				curr_max = Math.max(curr_max, min - as[i]);
				curr_max = Math.max(curr_max, max - as[i]);
			}
			// *
			{
				curr_min = Math.min(curr_min, min * as[i]);
				curr_min = Math.min(curr_min, max * as[i]);
				curr_max = Math.max(curr_max, min * as[i]);
				curr_max = Math.max(curr_max, max * as[i]);
			}
			
			min = curr_min;
			max = curr_max;
		}
		
		System.out.println(max);
	}
}
0