結果

問題 No.2548 Problem Selection
ユーザー 👑 kakel-sankakel-san
提出日時 2024-01-29 23:13:45
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 268 ms / 2,000 ms
コード長 812 bytes
コンパイル時間 14,300 ms
コンパイル使用メモリ 158,992 KB
実行使用メモリ 179,448 KB
最終ジャッジ日時 2024-01-29 23:14:06
合計ジャッジ時間 21,227 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 199 ms
41,252 KB
testcase_01 AC 123 ms
35,748 KB
testcase_02 AC 236 ms
47,944 KB
testcase_03 AC 101 ms
34,340 KB
testcase_04 AC 200 ms
39,332 KB
testcase_05 AC 237 ms
47,732 KB
testcase_06 AC 103 ms
34,468 KB
testcase_07 AC 195 ms
40,996 KB
testcase_08 AC 208 ms
41,764 KB
testcase_09 AC 222 ms
46,216 KB
testcase_10 AC 268 ms
48,424 KB
testcase_11 AC 240 ms
48,424 KB
testcase_12 AC 242 ms
48,424 KB
testcase_13 AC 79 ms
32,804 KB
testcase_14 AC 76 ms
32,548 KB
testcase_15 AC 80 ms
32,804 KB
testcase_16 AC 80 ms
32,804 KB
testcase_17 AC 79 ms
32,804 KB
testcase_18 AC 80 ms
32,804 KB
testcase_19 AC 79 ms
32,804 KB
testcase_20 AC 77 ms
32,548 KB
testcase_21 AC 79 ms
32,804 KB
testcase_22 AC 81 ms
32,804 KB
testcase_23 AC 80 ms
32,804 KB
testcase_24 AC 81 ms
32,804 KB
testcase_25 AC 79 ms
32,804 KB
testcase_26 AC 80 ms
179,448 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (106 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();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, m) = (c[0], c[1]);
        var a = NList;
        Array.Sort(a);
        var d2 = new long[n];
        for (var i = 1; i < n; ++i) d2[i] = d2[i - 1] + (long)(a[i] - a[i - 1]) * (a[i] - a[i - 1]);
        var ans = long.MaxValue;
        for (var i = 0; i < n; ++i) if (i + m - 1 < n) ans = Math.Min(ans, d2[i + m - 1] - d2[i]);
        WriteLine(ans);
    }
}
0