結果
問題 | No.2359 A in S ? |
ユーザー |
|
提出日時 | 2023-11-08 22:33:43 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 1,760 ms / 2,000 ms |
コード長 | 2,738 bytes |
コンパイル時間 | 10,014 ms |
コンパイル使用メモリ | 168,352 KB |
実行使用メモリ | 237,580 KB |
最終ジャッジ日時 | 2024-09-25 23:56:10 |
合計ジャッジ時間 | 20,780 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (100 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) 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[][] 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 map = NArr(n);var a = NList;var alist = new List<(int id, int ai)>(a.Length);for (var i = 0; i < a.Length; ++i) alist.Add((i, a[i]));alist.Sort((l, r) => l.ai.CompareTo(r.ai));var amap = new List<(int id, int ai)>[100001];for (var i = 0; i < amap.Length; ++i) amap[i] = new List<(int id, int ai)>();foreach (var al in alist) amap[al.ai].Add(al);var border = 317;var tbl = new List<(int id, int flg, int time, int y)>[border];for (var i = 0; i < tbl.Length; ++i) tbl[i] = new List<(int id, int flg, int time, int y)>();var exists = new bool[100001];foreach (var ai in a) exists[ai] = true;var ans = new int[m];for (var i = 0; i < map.Length; ++i){if (map[i][2] < tbl.Length){tbl[map[i][2]].Add((i, 1, map[i][0], map[i][3]));tbl[map[i][2]].Add((i, -1, map[i][1] + 1, map[i][3]));}else{for (var j = map[i][3]; j <= 100000; j += map[i][2]){if (map[i][0] <= j && j <= map[i][1]){foreach (var al in amap[j]) ++ans[al.id];}}}}for (var i = 1; i < tbl.Length; ++i){if (tbl[i].Count == 0) continue;// WriteLine("i=" + i);tbl[i].Sort((l, r) => l.time.CompareTo(r.time));var count = new int[i];var pos = 0;for (var j = 0; j < alist.Count; ++j){while (pos < tbl[i].Count && tbl[i][pos].time <= alist[j].ai){count[tbl[i][pos].y] += tbl[i][pos].flg;// WriteLine($"count[{tbl[i][pos].y}] += {tbl[i][pos].flg} (time: {tbl[i][pos].time})");++pos;}// WriteLine($"id:{alist[j].id}, a:{alist[j].ai}, count:{string.Join(" ", count)}");ans[alist[j].id] += count[alist[j].ai % i];}}WriteLine(string.Join("\n", ans));}}