結果

問題 No.999 てん vs. ほむ
ユーザー 抹茶アイス抹茶アイス
提出日時 2023-08-23 14:37:55
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,174 bytes
コンパイル時間 4,184 ms
コンパイル使用メモリ 103,132 KB
実行使用メモリ 26,416 KB
最終ジャッジ日時 2023-08-23 14:38:06
合計ジャッジ時間 9,577 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
21,836 KB
testcase_01 AC 62 ms
21,808 KB
testcase_02 AC 63 ms
19,728 KB
testcase_03 AC 62 ms
21,868 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 70 ms
24,012 KB
testcase_08 WA -
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Numerics;

namespace yukicoder
{
    public class Program
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(x => long.Parse(x)).ToList();
            long s = 0;
            long v = 0;
            while (a.Count > 0)
            {
                while (a.Count > 0 && a[a.Count - 1] - a[a.Count - 2] >= v)
                {
                    s += a[a.Count - 1] - a[a.Count - 2];
                    a.RemoveAt(a.Count - 1);
                    a.RemoveAt(a.Count - 1);
                }
                if(a.Count > 0)
                {
                    v = a[a.Count - 1] - a[a.Count - 2];
                }
                while (a.Count > 0 && a[0] - a[1] >= v)
                {
                    s += a[0] - a[1];
                    a.RemoveAt(0);
                    a.RemoveAt(0);
                }
                if (a.Count > 0)
                {
                    v = a[0] - a[1];
                }
            }
            Console.WriteLine(s);
        }
    }
}
0