結果

問題 No.505 カードの数式2
ユーザー Tomohiko HasegawaTomohiko Hasegawa
提出日時 2019-03-27 16:23:12
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 2,013 bytes
コンパイル時間 4,908 ms
コンパイル使用メモリ 109,688 KB
実行使用メモリ 25,608 KB
最終ジャッジ日時 2024-04-19 10:01:26
合計ジャッジ時間 4,150 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
18,048 KB
testcase_01 AC 23 ms
18,176 KB
testcase_02 AC 23 ms
18,176 KB
testcase_03 AC 23 ms
18,176 KB
testcase_04 RE -
testcase_05 AC 22 ms
18,176 KB
testcase_06 AC 24 ms
17,920 KB
testcase_07 RE -
testcase_08 AC 21 ms
18,176 KB
testcase_09 RE -
testcase_10 AC 22 ms
18,176 KB
testcase_11 AC 23 ms
18,176 KB
testcase_12 AC 23 ms
17,792 KB
testcase_13 RE -
testcase_14 AC 22 ms
17,920 KB
testcase_15 AC 22 ms
18,048 KB
testcase_16 RE -
testcase_17 AC 22 ms
18,048 KB
testcase_18 AC 22 ms
17,920 KB
testcase_19 RE -
testcase_20 AC 23 ms
17,792 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 22 ms
17,920 KB
testcase_27 AC 22 ms
18,048 KB
testcase_28 AC 22 ms
18,304 KB
testcase_29 AC 22 ms
17,792 KB
testcase_30 AC 22 ms
18,048 KB
testcase_31 AC 22 ms
18,048 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.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.DP
{
    class yuki505
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] array = ReadInts();
            long[,] dp = new long[n, 2];//plus max/minus max
            dp[0, 0] = array[0];
            dp[0, 1] = array[0];
            for(int i = 1; i < n; i++)
            {
                dp[i, 0] = Max(
                    Max(
                    Max(dp[i - 1, 0] + array[i], dp[i - 1, 0] - array[i]),
                    Max(dp[i - 1, 0] * array[i], dp[i - 1, 0] / array[i])),
                    Max(
                    Max(dp[i - 1, 1] + array[i], dp[i - 1, 1] - array[i]),
                    Max(dp[i - 1, 1] * array[i], dp[i - 1, 1] / array[i])));
                dp[i, 1] = Min(
                    Min(
                    Min(dp[i - 1, 0] + array[i], dp[i - 1, 0] - array[i]),
                    Min(dp[i - 1, 0] * array[i], dp[i - 1, 0] / array[i])),
                    Min(
                    Min(dp[i - 1, 1] + array[i], dp[i - 1, 1] - array[i]),
                    Min(dp[i - 1, 1] * array[i], dp[i - 1, 1] / array[i])));
            }
            WriteLine(dp[n - 1, 0]);
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}
0