結果
問題 |
No.1110 好きな歌
|
ユーザー |
|
提出日時 | 2025-07-13 23:31:55 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 162 ms / 5,000 ms |
コード長 | 1,141 bytes |
コンパイル時間 | 6,799 ms |
コンパイル使用メモリ | 170,404 KB |
実行使用メモリ | 212,736 KB |
最終ジャッジ日時 | 2025-07-13 23:32:12 |
合計ジャッジ時間 | 16,332 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 51 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (90 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
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[] NMi => ReadLine().Split().Select(c => int.Parse(c) - 1).ToArray(); static int[][] NMap(int n) => Enumerable.Repeat(0, n).Select(_ => NMi).ToArray(); static int[] LList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => int.Parse(ReadLine())).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (n, d) = (c[0], c[1]); var a = LList(n); var sort = new List<(int id, int val)>(); for (var i = 0; i < n; ++i) sort.Add((i, a[i])); sort.Sort((l, r) => l.val.CompareTo(r.val)); var pos = 0; var ans = new int[n]; for (var i = 0; i < n; ++i) { while (pos < n && sort[i].val - d >= sort[pos].val) ++pos; ans[sort[i].id] = pos; } WriteLine(string.Join("\n", ans)); } }