結果

問題 No.2549 Paint Eggs
ユーザー heno239heno239
提出日時 2024-02-06 17:20:52
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 235 ms / 2,000 ms
コード長 1,819 bytes
コンパイル時間 7,414 ms
コンパイル使用メモリ 158,544 KB
実行使用メモリ 226,108 KB
最終ジャッジ日時 2024-02-06 17:21:15
合計ジャッジ時間 19,094 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
33,188 KB
testcase_01 AC 83 ms
33,188 KB
testcase_02 AC 77 ms
33,188 KB
testcase_03 AC 78 ms
33,188 KB
testcase_04 AC 81 ms
33,188 KB
testcase_05 AC 81 ms
33,188 KB
testcase_06 AC 80 ms
33,188 KB
testcase_07 AC 81 ms
33,188 KB
testcase_08 AC 82 ms
33,060 KB
testcase_09 AC 81 ms
33,188 KB
testcase_10 AC 194 ms
69,948 KB
testcase_11 AC 154 ms
65,428 KB
testcase_12 AC 153 ms
59,940 KB
testcase_13 AC 167 ms
67,892 KB
testcase_14 AC 130 ms
56,388 KB
testcase_15 AC 84 ms
35,748 KB
testcase_16 AC 154 ms
65,664 KB
testcase_17 AC 130 ms
54,820 KB
testcase_18 AC 132 ms
52,972 KB
testcase_19 AC 143 ms
59,428 KB
testcase_20 AC 227 ms
78,584 KB
testcase_21 AC 206 ms
78,584 KB
testcase_22 AC 210 ms
78,584 KB
testcase_23 AC 203 ms
78,588 KB
testcase_24 AC 206 ms
78,580 KB
testcase_25 AC 235 ms
78,584 KB
testcase_26 AC 216 ms
78,576 KB
testcase_27 AC 207 ms
78,588 KB
testcase_28 AC 210 ms
78,576 KB
testcase_29 AC 212 ms
78,576 KB
testcase_30 AC 228 ms
78,580 KB
testcase_31 AC 207 ms
78,580 KB
testcase_32 AC 208 ms
78,580 KB
testcase_33 AC 207 ms
78,580 KB
testcase_34 AC 208 ms
78,576 KB
testcase_35 AC 214 ms
78,580 KB
testcase_36 AC 231 ms
78,584 KB
testcase_37 AC 211 ms
78,580 KB
testcase_38 AC 220 ms
78,588 KB
testcase_39 AC 223 ms
78,584 KB
testcase_40 AC 222 ms
78,584 KB
testcase_41 AC 232 ms
78,588 KB
testcase_42 AC 209 ms
78,576 KB
testcase_43 AC 209 ms
78,588 KB
testcase_44 AC 208 ms
226,108 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (110 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System.Collections;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

internal class Program
{
    private const long mod = 998244353;
    private const long mod17 = 1000000007;
    private const long INF = mod17 * mod17;
    
    public static void Main(string[] args)
    {
        var line = getar();
        int n = line[0], m = line[1], k = line[2];
        var c = getar();
        for (int i = 0; i < n; i++) c[i]--;
        var a = getar();
        long ans = INF;
        for (int i = 0; i < m; i++)
        {
            long val = (long)a[i] * k;
            ans = Math.Min(ans, val);
        }

        List<List<int>> ids = new List<List<int>>(m);
        for(int i=0;i<m;i++)ids.Add(new List<int>());
        for (int i = 0; i < n; i++)
        {
            ids[c[i]].Add(i);
        }

        for (int i = 0; i < m; i++)
        {
            if (ids[i].Count() == 0) continue;
            int r = 0;
            for (int l = 0; l < ids[i].Count(); l++)
            {
                while (r + 1 < ids[i].Count() && ids[i][r + 1] - ids[i][l] < k) r++;
                int num = r - l + 1;
                long val = (long)(k - num) * a[i];
                ans = Math.Min(ans, val);
            }
        }
        Console.WriteLine(ans);
    }
    public class lower_bound<T> : IComparer<T> where T : IComparable<T>
    {
        public int Compare(T x, T y)
        {
            return 0 <= x.CompareTo(y) ? 1 : -1;
        }
    }
    public static List<T> mkar<T>(int n, T val)
    {
        List<T> res = new List<T>(n);
        for(int i=0;i<n;i++)res.Add(val);
        return res;
    }

    public static int[] getar()
    {
        var res = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        return res;
    }
}
0