結果

問題 No.2372 既視感
ユーザー 👑 kakel-sankakel-san
提出日時 2023-07-07 21:41:10
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 1,779 bytes
コンパイル時間 1,879 ms
コンパイル使用メモリ 64,224 KB
実行使用メモリ 23,948 KB
最終ジャッジ日時 2023-09-28 22:42:54
合計ジャッジ時間 5,172 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
21,628 KB
testcase_01 AC 68 ms
23,864 KB
testcase_02 AC 65 ms
21,796 KB
testcase_03 AC 67 ms
19,848 KB
testcase_04 AC 67 ms
23,724 KB
testcase_05 AC 67 ms
23,868 KB
testcase_06 AC 67 ms
23,720 KB
testcase_07 AC 65 ms
21,708 KB
testcase_08 AC 69 ms
19,788 KB
testcase_09 AC 68 ms
19,808 KB
testcase_10 AC 68 ms
21,896 KB
testcase_11 AC 69 ms
21,608 KB
testcase_12 AC 67 ms
23,736 KB
testcase_13 AC 70 ms
19,776 KB
testcase_14 AC 68 ms
19,776 KB
testcase_15 AC 69 ms
23,828 KB
testcase_16 AC 69 ms
21,656 KB
testcase_17 AC 67 ms
21,732 KB
testcase_18 AC 70 ms
23,948 KB
testcase_19 AC 68 ms
21,744 KB
testcase_20 AC 68 ms
21,740 KB
testcase_21 AC 68 ms
23,712 KB
testcase_22 AC 68 ms
21,828 KB
testcase_23 AC 69 ms
21,640 KB
testcase_24 AC 69 ms
23,760 KB
testcase_25 AC 69 ms
23,764 KB
testcase_26 AC 69 ms
21,848 KB
testcase_27 AC 70 ms
21,820 KB
testcase_28 AC 72 ms
23,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, k, q) = (c[0], c[1], c[2]);
        var que = new Queue<string>();
        var dic = new Dictionary<string, int>();
        var ans = new List<int>();
        for (var i = 0; i < q; ++i)
        {
            var r = NN;
            if (r == 1)
            {
                var s = ReadLine();
                que.Enqueue(s);
                if (dic.ContainsKey(s)) ++dic[s];
                else dic[s] = 1;
            }
            else
            {
                var time = 0;
                var que2 = new Queue<string>();
                for (var j = 0; j < 6; ++j)
                {
                    var s = ReadLine().Split();
                    var (t, d) = (s[0], int.Parse(s[1]));
                    if (dic.ContainsKey(t) && dic[t] > 0) d = Math.Min(d, k);
                    time += d;
                    if (time <= 60)
                    {
                        que2.Enqueue(t);
                    }
                }
                ans.Add(que2.Count);
                while (que2.Count > 0)
                {
                    var u = que2.Dequeue();
                    que.Enqueue(u);
                    if (dic.ContainsKey(u)) ++dic[u];
                    else dic[u] = 1;
                }
            }
            while (que.Count > n) --dic[que.Dequeue()];
        }
        WriteLine(string.Join("\n", ans));
    }
}
0