結果

問題 No.451 575
ユーザー kuuso1kuuso1
提出日時 2016-12-02 01:33:07
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 281 ms / 2,000 ms
コード長 1,769 bytes
コンパイル時間 3,759 ms
コンパイル使用メモリ 105,852 KB
実行使用メモリ 46,252 KB
最終ジャッジ日時 2023-08-22 13:19:59
合計ジャッジ時間 9,561 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
21,068 KB
testcase_01 AC 66 ms
20,912 KB
testcase_02 AC 62 ms
22,940 KB
testcase_03 AC 67 ms
20,956 KB
testcase_04 AC 62 ms
20,952 KB
testcase_05 AC 66 ms
20,952 KB
testcase_06 AC 85 ms
26,408 KB
testcase_07 AC 189 ms
38,544 KB
testcase_08 AC 67 ms
25,088 KB
testcase_09 AC 68 ms
18,924 KB
testcase_10 AC 120 ms
32,560 KB
testcase_11 AC 226 ms
44,152 KB
testcase_12 AC 277 ms
46,252 KB
testcase_13 AC 273 ms
43,772 KB
testcase_14 AC 63 ms
22,940 KB
testcase_15 AC 68 ms
20,980 KB
testcase_16 AC 83 ms
26,180 KB
testcase_17 AC 185 ms
37,664 KB
testcase_18 AC 183 ms
37,624 KB
testcase_19 AC 144 ms
33,928 KB
testcase_20 AC 75 ms
25,116 KB
testcase_21 AC 68 ms
20,940 KB
testcase_22 AC 67 ms
20,960 KB
testcase_23 AC 281 ms
44,184 KB
testcase_24 AC 182 ms
36,764 KB
testcase_25 AC 66 ms
21,028 KB
testcase_26 AC 62 ms
20,992 KB
testcase_27 AC 63 ms
20,868 KB
testcase_28 AC 64 ms
20,968 KB
testcase_29 AC 76 ms
27,652 KB
testcase_30 AC 186 ms
35,516 KB
testcase_31 AC 61 ms
20,896 KB
testcase_32 AC 104 ms
29,856 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using BI = System.Numerics.BigInteger;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		BI lmin = 1;
		BI rmax = (BI)1e18;
		
		BI[] A = new BI[N+1];
		A[0] = 0;
		BI sig = 1;
		for(int i=1;i<=N;i++){
			A[i] = (B[i-1] - A[i-1]) * sig;
			sig *= -1;
		}
		
		BI ll = lmin;
		BI rr = rmax;
		
		for(int i=0;i<=N;i++){
			if(i%4 == 0 || i%4 == 3){
				if(A[i]+rr > rmax) rr -= (A[i] + rr - rmax);
				if(A[i]+ll < lmin) ll += (lmin - (A[i] + ll));
			}else{
				if(A[i]-rr < lmin) rr -= (lmin - (A[i] - rr));
				if(A[i]-ll > rmax) ll += ((A[i] - ll) - rmax);
			}
		}
		
		if(lmin <= ll && ll <= rr && rr <= rmax){
			A[0] = ll;
			sig = 1;
			for(int i=1;i<=N;i++){
				A[i] = (B[i-1] - A[i-1]) * sig;
				sig *= -1;
			}
			Console.WriteLine(N+1);
			Console.WriteLine(String.Join("\n",A));
			return;
		}
		Console.WriteLine(-1);
	}
	int N;
	BI[] B;
	public Sol(){
		N = ri();
		B = new BI[N];
		for(int i=0;i<N;i++) B[i] = (BI) rl();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}
0