結果

問題 No.3017 交互浴
コンテスト
ユーザー aketijyuuzou
提出日時 2025-01-27 21:30:11
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 1,199 ms / 2,000 ms
コード長 2,253 bytes
コンパイル時間 4,065 ms
コンパイル使用メモリ 108,800 KB
実行使用メモリ 48,384 KB
最終ジャッジ日時 2025-01-27 21:31:18
合計ジャッジ時間 62,695 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 55
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;

// https://yukicoder.me/problems/no/3017
class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("5");
            WillReturn.Add("7 3 2 4 5");
            //7
            //4
            //6
            //3
            //7
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        long[] HArr = InputList[1].Split(' ').Select(pX => long.Parse(pX)).ToArray();

        var InsLinkedList = new LinkedList<RunLenInfo>();
        var InitJyoutai = new RunLenInfo();
        InitJyoutai.Len = 1000000000000000000;
        InitJyoutai.Color = '緑';
        InsLinkedList.AddFirst(InitJyoutai);

        long WaterLen = 0;
        for (long I = 0; I <= HArr.GetUpperBound(0); I++) {
            var CurrJyoutai = new RunLenInfo();
            CurrJyoutai.Len = HArr[I];
            CurrJyoutai.Color = '緑';
            if (I % 2 == 0) {
                CurrJyoutai.Color = '水';
            }

            long RestRemoveLen = HArr[I];
            while (true) {
                RunLenInfo TopItem = InsLinkedList.First.Value;

                long CurrRemoveLen = Math.Min(RestRemoveLen, TopItem.Len);
                TopItem.Len -= CurrRemoveLen;
                RestRemoveLen -= CurrRemoveLen;

                if (TopItem.Color == '水') {
                    WaterLen -= CurrRemoveLen;
                }
                if (TopItem.Len == 0) {
                    InsLinkedList.RemoveFirst();
                }

                if (RestRemoveLen == 0) {
                    break;
                }
            }

            InsLinkedList.AddFirst(CurrJyoutai);
            if (CurrJyoutai.Color == '水') {
                WaterLen += CurrJyoutai.Len;
            }
            Console.WriteLine(WaterLen);
        }
    }

    class RunLenInfo
    {
        internal long Len;
        internal char Color;
    }
}
0