結果
問題 | No.505 カードの数式2 |
ユーザー | uafr_cs |
提出日時 | 2017-10-30 18:03:01 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 129 ms / 2,000 ms |
コード長 | 1,407 bytes |
コンパイル時間 | 2,385 ms |
コンパイル使用メモリ | 77,460 KB |
実行使用メモリ | 41,324 KB |
最終ジャッジ日時 | 2024-04-26 17:48:51 |
合計ジャッジ時間 | 7,079 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 126 ms
41,320 KB |
testcase_01 | AC | 118 ms
40,056 KB |
testcase_02 | AC | 128 ms
41,184 KB |
testcase_03 | AC | 112 ms
40,200 KB |
testcase_04 | AC | 128 ms
41,000 KB |
testcase_05 | AC | 117 ms
39,820 KB |
testcase_06 | AC | 124 ms
41,208 KB |
testcase_07 | AC | 119 ms
40,772 KB |
testcase_08 | AC | 126 ms
40,952 KB |
testcase_09 | AC | 117 ms
39,724 KB |
testcase_10 | AC | 122 ms
41,056 KB |
testcase_11 | AC | 116 ms
39,812 KB |
testcase_12 | AC | 118 ms
40,732 KB |
testcase_13 | AC | 111 ms
39,944 KB |
testcase_14 | AC | 111 ms
40,268 KB |
testcase_15 | AC | 124 ms
40,900 KB |
testcase_16 | AC | 126 ms
41,296 KB |
testcase_17 | AC | 112 ms
40,056 KB |
testcase_18 | AC | 109 ms
40,348 KB |
testcase_19 | AC | 125 ms
41,220 KB |
testcase_20 | AC | 125 ms
41,064 KB |
testcase_21 | AC | 129 ms
41,300 KB |
testcase_22 | AC | 112 ms
40,384 KB |
testcase_23 | AC | 118 ms
40,284 KB |
testcase_24 | AC | 110 ms
40,032 KB |
testcase_25 | AC | 117 ms
40,804 KB |
testcase_26 | AC | 123 ms
40,072 KB |
testcase_27 | AC | 129 ms
41,300 KB |
testcase_28 | AC | 114 ms
40,176 KB |
testcase_29 | AC | 129 ms
41,192 KB |
testcase_30 | AC | 114 ms
40,264 KB |
testcase_31 | AC | 127 ms
41,324 KB |
ソースコード
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]); } // * if(as[i] != 0){ 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); } }