結果

問題 No.2548 Problem Selection
ユーザー heno239heno239
提出日時 2024-02-06 15:52:03
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 1,345 bytes
コンパイル時間 6,965 ms
コンパイル使用メモリ 158,308 KB
実行使用メモリ 180,472 KB
最終ジャッジ日時 2024-02-06 15:52:16
合計ジャッジ時間 12,762 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 200 ms
41,380 KB
testcase_01 AC 128 ms
36,132 KB
testcase_02 AC 242 ms
48,080 KB
testcase_03 AC 101 ms
34,596 KB
testcase_04 AC 174 ms
39,588 KB
testcase_05 AC 239 ms
47,864 KB
testcase_06 AC 107 ms
34,852 KB
testcase_07 AC 200 ms
41,124 KB
testcase_08 AC 213 ms
42,020 KB
testcase_09 AC 220 ms
46,352 KB
testcase_10 AC 245 ms
48,560 KB
testcase_11 AC 244 ms
48,560 KB
testcase_12 AC 247 ms
48,552 KB
testcase_13 AC 82 ms
33,060 KB
testcase_14 AC 82 ms
32,804 KB
testcase_15 AC 84 ms
33,060 KB
testcase_16 AC 83 ms
33,060 KB
testcase_17 AC 85 ms
33,060 KB
testcase_18 AC 84 ms
33,060 KB
testcase_19 AC 84 ms
33,060 KB
testcase_20 AC 81 ms
32,804 KB
testcase_21 AC 79 ms
33,060 KB
testcase_22 AC 79 ms
33,060 KB
testcase_23 AC 77 ms
33,060 KB
testcase_24 AC 78 ms
33,060 KB
testcase_25 AC 80 ms
33,060 KB
testcase_26 AC 81 ms
180,472 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (104 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];
        var a = getar();
        Array.Sort(a);
        List<long> rd = mkar(n, (long)0);
        for (int i = 0; i + 1 < n; i++)
        {
            long dif = a[i + 1] - a[i];
            rd[i + 1] = rd[i] + dif * dif;
        }

        long ans = INF;
        for (int i = 0; i < n - (m - 1); i++)
        {
            long val = rd[i + m - 1] - rd[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