結果

問題 No.451 575
ユーザー fal_rndfal_rnd
提出日時 2016-12-04 01:15:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,238 ms / 2,000 ms
コード長 862 bytes
コンパイル時間 4,333 ms
コンパイル使用メモリ 78,952 KB
実行使用メモリ 70,760 KB
最終ジャッジ日時 2023-08-22 13:47:09
合計ジャッジ時間 18,329 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
56,036 KB
testcase_01 AC 116 ms
55,880 KB
testcase_02 AC 118 ms
55,440 KB
testcase_03 AC 119 ms
55,552 KB
testcase_04 AC 117 ms
55,248 KB
testcase_05 AC 193 ms
58,944 KB
testcase_06 AC 268 ms
60,772 KB
testcase_07 AC 605 ms
64,520 KB
testcase_08 AC 121 ms
55,796 KB
testcase_09 AC 205 ms
56,484 KB
testcase_10 AC 556 ms
63,000 KB
testcase_11 AC 1,070 ms
68,260 KB
testcase_12 AC 1,183 ms
69,852 KB
testcase_13 AC 1,189 ms
69,932 KB
testcase_14 AC 130 ms
56,068 KB
testcase_15 AC 191 ms
58,808 KB
testcase_16 AC 283 ms
60,868 KB
testcase_17 AC 617 ms
64,424 KB
testcase_18 AC 600 ms
64,484 KB
testcase_19 AC 506 ms
61,856 KB
testcase_20 AC 267 ms
60,744 KB
testcase_21 AC 216 ms
56,512 KB
testcase_22 AC 126 ms
56,200 KB
testcase_23 AC 1,238 ms
70,760 KB
testcase_24 AC 844 ms
68,540 KB
testcase_25 AC 124 ms
55,464 KB
testcase_26 AC 121 ms
55,284 KB
testcase_27 AC 154 ms
56,192 KB
testcase_28 AC 171 ms
54,752 KB
testcase_29 AC 234 ms
60,324 KB
testcase_30 AC 608 ms
64,668 KB
testcase_31 AC 118 ms
55,592 KB
testcase_32 AC 346 ms
60,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package src;

import java.util.*;
class B{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		long[] in  = new long[s.nextInt()];
		long[] out = new long[in.length+1];
		long buf=1;
		out[0]=buf;

		for(int i=0;i<in.length;++i) {
			in[i]=Long.parseLong(s.next());
			if(i%2==0) {
				buf=(out[i+1]=in[i]-buf);
			}else {
				buf=(out[i+1]=buf-in[i]);
			}
		}

		long b1=Long.MAX_VALUE;
		for(int i=0;i<out.length;i++) {
			if((i+1)%4>=2)
				b1=Math.min(b1, out[i]);
		}

		buf=b1;
		out[0]=buf;
		for(int i=0;i<in.length;++i) {
			if(i%2==0) {
				buf=(out[i+1]=in[i]-buf);
			}else {
				buf=(out[i+1]=buf-in[i]);
			}
		}


		for(int i=0;i<out.length;i++)
			if(out[i]<1) {
				System.out.println(-1);
				return;
			}
		System.out.println(out.length);
		for(int i=0;i<out.length;i++)
			System.out.println(out[i]);
	}
}
0