結果
問題 |
No.505 カードの数式2
|
ユーザー |
|
提出日時 | 2019-03-27 16:25:56 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,283 bytes |
コンパイル時間 | 1,246 ms |
コンパイル使用メモリ | 114,120 KB |
実行使用メモリ | 26,012 KB |
最終ジャッジ日時 | 2024-10-11 02:23:09 |
合計ジャッジ時間 | 3,027 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 WA * 5 |
コンパイルメッセージ
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.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++) { if (array[i] == 0) { dp[i, 0] = dp[i - 1, 0]; dp[i, 1] = dp[i, 1]; } else { 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); } } }