結果

問題 No.451 575
ユーザー eitahoeitaho
提出日時 2016-12-02 00:17:31
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 452 ms / 2,000 ms
コード長 2,964 bytes
コンパイル時間 4,759 ms
コンパイル使用メモリ 106,832 KB
実行使用メモリ 28,292 KB
最終ジャッジ日時 2023-08-22 12:34:19
合計ジャッジ時間 10,015 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
18,888 KB
testcase_01 AC 64 ms
20,820 KB
testcase_02 AC 62 ms
18,756 KB
testcase_03 AC 64 ms
21,032 KB
testcase_04 AC 62 ms
22,920 KB
testcase_05 AC 67 ms
21,000 KB
testcase_06 AC 85 ms
25,112 KB
testcase_07 AC 162 ms
28,292 KB
testcase_08 AC 64 ms
22,876 KB
testcase_09 AC 70 ms
21,052 KB
testcase_10 AC 161 ms
25,252 KB
testcase_11 AC 355 ms
27,916 KB
testcase_12 AC 443 ms
26,224 KB
testcase_13 AC 439 ms
26,212 KB
testcase_14 AC 65 ms
21,004 KB
testcase_15 AC 68 ms
20,928 KB
testcase_16 AC 84 ms
25,016 KB
testcase_17 AC 161 ms
28,200 KB
testcase_18 AC 160 ms
28,252 KB
testcase_19 AC 128 ms
25,572 KB
testcase_20 AC 81 ms
22,976 KB
testcase_21 AC 72 ms
22,892 KB
testcase_22 AC 66 ms
22,992 KB
testcase_23 AC 452 ms
28,280 KB
testcase_24 AC 285 ms
25,600 KB
testcase_25 AC 66 ms
23,104 KB
testcase_26 AC 64 ms
20,860 KB
testcase_27 AC 65 ms
20,912 KB
testcase_28 AC 65 ms
22,964 KB
testcase_29 AC 74 ms
22,968 KB
testcase_30 AC 162 ms
28,196 KB
testcase_31 AC 62 ms
22,940 KB
testcase_32 AC 95 ms
25,172 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.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int();
        var B = new long[N];
        for (int i = 0; i < N; i++) B[i] = Reader.Long();
        var A = new long[N + 1];

        BigInteger add = 0, sign = 1;
        BigInteger min = 1, max = B[0] - 1;

        for (int i = 0; i < N; i++)
        {
            if (i % 2 == 1)
                add -= B[i];
            else
            {
                add = B[i] - add;
                sign = -sign;
            }
            if (sign == 1) { if (1 - add > min) min = 1 - add; }
            else if (add - 1 < max) max = add - 1;
        }

        if (min > max || min <= 0) { Console.WriteLine(-1); return; }

        Console.WriteLine(N + 1);
        BigInteger x = max;
        Console.WriteLine(max);
        for (int i = 0; i < N; i++)
        {
            if (i % 2 == 0) x = B[i] - x;
            else x = x - B[i];
            Console.WriteLine(x);
        }
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}
0