結果

問題 No.555 世界史のレポート
ユーザー RisenRisen
提出日時 2017-08-11 23:54:57
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,220 bytes
コンパイル時間 822 ms
コンパイル使用メモリ 108,544 KB
実行使用メモリ 28,416 KB
最終ジャッジ日時 2024-04-20 23:56:33
合計ジャッジ時間 6,393 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,704 KB
testcase_01 AC 32 ms
20,480 KB
testcase_02 TLE -
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;

class Solution
{
    internal struct State
    {
        internal int Cost;
        internal int Length;
        internal int CopiedLength;

        internal State(int c, int l, int cl)
        {
            Cost = c;
            Length = l;
            CopiedLength = cl;
        }
    }

    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var c = vals[0];
        var v = vals[1];

        // cost -> length, copied length
        var states = new List<State>() { { new State(0, 1, 0) } };

        State best = states[0];
        while (states.Count > 0)
        {
            var cur = states.OrderBy(s => s.Cost).First();
            states.Remove(cur);

            if (cur.Length >= n)
            {
                best = cur;
                break;
            }

            // copy
            states.Add(new State(cur.Cost + c, cur.Length, cur.Length));
            // paste
            states.Add(new State(cur.Cost + v, cur.Length + cur.CopiedLength, cur.CopiedLength));
        }

        Console.WriteLine(best.Cost);
    }
}
0