結果

問題 No.2566 美しい整数列
ユーザー 👑 kakel-sankakel-san
提出日時 2023-12-02 15:46:09
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 256 ms / 2,000 ms
コード長 1,253 bytes
コンパイル時間 9,965 ms
コンパイル使用メモリ 158,632 KB
実行使用メモリ 223,660 KB
最終ジャッジ日時 2023-12-02 15:46:26
合計ジャッジ時間 16,042 ms
ジャッジサーバーID
(参考情報)
judge9 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
33,060 KB
testcase_01 AC 72 ms
33,060 KB
testcase_02 AC 72 ms
33,060 KB
testcase_03 AC 73 ms
33,060 KB
testcase_04 AC 231 ms
91,924 KB
testcase_05 AC 256 ms
100,288 KB
testcase_06 AC 185 ms
69,964 KB
testcase_07 AC 192 ms
77,800 KB
testcase_08 AC 185 ms
70,228 KB
testcase_09 AC 203 ms
77,672 KB
testcase_10 AC 218 ms
77,672 KB
testcase_11 AC 205 ms
77,452 KB
testcase_12 AC 207 ms
77,616 KB
testcase_13 AC 204 ms
77,452 KB
testcase_14 AC 205 ms
77,560 KB
testcase_15 AC 212 ms
77,560 KB
testcase_16 AC 230 ms
79,860 KB
testcase_17 AC 220 ms
81,936 KB
testcase_18 AC 221 ms
81,940 KB
testcase_19 AC 163 ms
70,892 KB
testcase_20 AC 204 ms
79,816 KB
testcase_21 AC 209 ms
79,840 KB
testcase_22 AC 176 ms
68,752 KB
testcase_23 AC 177 ms
223,660 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (101 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;
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();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    static int[] NMi => ReadLine().Split().Select(c => int.Parse(c) - 1).ToArray();
    static int[][] NMap(int n) => Enumerable.Repeat(0, n).Select(_ => NMi).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, m) = (c[0], c[1]);
        var a = NList;
        var b = NList;
        c = NList;
        var sum = 0L;
        foreach (var ci in c) sum += ci;
        var dic = new Dictionary<long, long>();
        dic[a[0]] = c[0];
        var sub = 0L;
        for (var i = 1; i < n; ++i)
        {
            sub += b[(i - 1) % m];
            var ta1 = a[i] - sub;
            if (dic.ContainsKey(ta1)) dic[ta1] += c[i];
            else dic[ta1] = c[i];
        }
        var ans = long.MaxValue;
        foreach (var kv in dic) ans = Math.Min(ans, sum - kv.Value);
        WriteLine(ans);
    }
}
0