結果
問題 |
No.451 575
|
ユーザー |
![]() |
提出日時 | 2016-12-02 00:36:45 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,571 bytes |
コンパイル時間 | 1,714 ms |
コンパイル使用メモリ | 107,776 KB |
実行使用メモリ | 40,760 KB |
最終ジャッジ日時 | 2024-12-16 07:49:19 |
合計ジャッジ時間 | 6,360 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 WA * 8 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ long lmin = 1; long rmax = (long)1e18; long l,r,c; l = lmin; r = rmax+1; while(r-l>0){ c = (l+r)/2; long[] A = new long[N+1]; A[0] = c; int of = 0; long sig = 1; for(int i=1;i<=N;i++){ A[i] = (B[i-1]-A[i-1])*sig; if(A[i] > rmax){ of = 1; break; } if(A[i] < lmin){ of = -1; break; } sig *= -1; } //Console.WriteLine("c:{0},of:{1}",c,of); if(of == 0){ Console.WriteLine(N+1); Console.WriteLine(String.Join("\n",A)); return; } if(of == 1){ l = c; }else{ r = c; } } Console.WriteLine(-1); } int N; long[] B; public Sol(){ N = ri(); B = new long[N]; for(int i=0;i<N;i++) B[i] = 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));} }