結果
問題 |
No.3017 交互浴
|
ユーザー |
![]() |
提出日時 | 2025-01-27 21:26:12 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 1,097 ms / 2,000 ms |
コード長 | 2,496 bytes |
コンパイル時間 | 4,454 ms |
コンパイル使用メモリ | 113,260 KB |
実行使用メモリ | 56,164 KB |
最終ジャッジ日時 | 2025-01-27 21:27:19 |
合計ジャッジ時間 | 65,093 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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.
ソースコード
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("■■■デバッグ情報■■■"); //foreach (RunLenInfo EachInfo in InsLinkedList) { // Console.WriteLine("長さ={0},色={1}", EachInfo.Len, EachInfo.Color); //} Console.WriteLine(WaterLen); } } class RunLenInfo { internal long Len; internal char Color; } }