結果

問題 No.505 カードの数式2
ユーザー bluemegane
提出日時 2018-09-13 17:44:44
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 616 bytes
コンパイル時間 877 ms
コンパイル使用メモリ 110,048 KB
実行使用メモリ 27,248 KB
最終ジャッジ日時 2024-07-01 04:28:17
合計ジャッジ時間 2,775 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 WA * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, long.Parse);
        var res = a[0];
        for (int i = 1; i < n; i++)
        {
            var t = new long[4];
            t[0] = res + a[i];
            t[1] = res * a[i];
            t[2] = res - a[i];
            if (a[i] != 0) t[3] = res / a[i];
            else t[3] = int.MinValue;
            res = t.Max();
        }
        Console.WriteLine(res);
    }
}
0