結果
問題 | No.451 575 |
ユーザー | hermione17 |
提出日時 | 2016-12-17 00:20:38 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,146 bytes |
コンパイル時間 | 3,734 ms |
コンパイル使用メモリ | 74,096 KB |
実行使用メモリ | 79,848 KB |
最終ジャッジ日時 | 2023-09-26 22:34:10 |
合計ジャッジ時間 | 19,139 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 111 ms
55,708 KB |
testcase_01 | AC | 117 ms
55,876 KB |
testcase_02 | AC | 110 ms
55,688 KB |
testcase_03 | AC | 113 ms
55,520 KB |
testcase_04 | AC | 112 ms
55,688 KB |
testcase_05 | AC | 206 ms
59,376 KB |
testcase_06 | AC | 305 ms
60,676 KB |
testcase_07 | AC | 606 ms
62,868 KB |
testcase_08 | AC | 112 ms
55,680 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 1,256 ms
79,848 KB |
testcase_14 | AC | 133 ms
55,872 KB |
testcase_15 | AC | 209 ms
58,896 KB |
testcase_16 | AC | 333 ms
60,796 KB |
testcase_17 | AC | 640 ms
63,064 KB |
testcase_18 | AC | 631 ms
62,524 KB |
testcase_19 | AC | 525 ms
60,856 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 117 ms
55,480 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 121 ms
55,528 KB |
testcase_26 | AC | 116 ms
55,660 KB |
testcase_27 | AC | 169 ms
55,924 KB |
testcase_28 | AC | 180 ms
55,904 KB |
testcase_29 | AC | 278 ms
60,100 KB |
testcase_30 | AC | 601 ms
63,016 KB |
testcase_31 | AC | 113 ms
55,956 KB |
testcase_32 | AC | 406 ms
58,788 KB |
ソースコード
import java.io.PrintStream; import java.util.Scanner; public class Y451 { Scanner in = new Scanner(System.in); PrintStream out = new PrintStream(System.out); Y451() throws Exception { int n = in.nextInt(); long[] b = new long[n]; for (int i = 0; i < n; i++) { b[i] = in.nextLong(); } long[] a = new long[n+1]; final long INF = 1000_000_000__000_000_000L; a[0] = 1; for (int i = 0; i < n; i++) { if (i % 2 == 0) { a[i+1] = b[i] - a[i]; } else { a[i+1] = a[i] - b[i]; } } for (int i = 1; i <= n; i++) { if (a[i] < 1 && (i % 4 == 0 || i % 4 == 3)) { a[0] = Math.max(a[0], -a[i] + 1); } if (a[i] > INF && (i % 4 == 1 || i % 4 == 2)) { a[0] = Math.max(a[0], a[i] - INF + 1); } } for (int i = 0; i < n; i++) { if (i % 2 == 0) { a[i+1] = b[i] - a[i]; } else { a[i+1] = a[i] - b[i]; } } for (int i = 0; i <= n; i++) { if (a[i] < 1 || INF < a[i]) { out.println(-1); return; } } out.println(n+1); for (int i = 0; i <= n; i++) { out.println(a[i]); } } public static void main(String argv[]) throws Exception { new Y451(); } }