結果

問題 No.2359 A in S ?
ユーザー 👑 kakel-sankakel-san
提出日時 2023-11-08 22:43:39
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 547 ms / 2,000 ms
コード長 2,358 bytes
コンパイル時間 7,483 ms
コンパイル使用メモリ 158,380 KB
実行使用メモリ 227,224 KB
最終ジャッジ日時 2023-11-08 22:43:55
合計ジャッジ時間 15,904 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
34,212 KB
testcase_01 AC 96 ms
34,212 KB
testcase_02 AC 95 ms
34,596 KB
testcase_03 AC 87 ms
33,316 KB
testcase_04 AC 335 ms
80,432 KB
testcase_05 AC 438 ms
70,616 KB
testcase_06 AC 341 ms
80,484 KB
testcase_07 AC 264 ms
70,076 KB
testcase_08 AC 547 ms
72,024 KB
testcase_09 AC 314 ms
81,268 KB
testcase_10 AC 467 ms
70,936 KB
testcase_11 AC 502 ms
71,440 KB
testcase_12 AC 330 ms
80,688 KB
testcase_13 AC 343 ms
81,064 KB
testcase_14 AC 364 ms
81,496 KB
testcase_15 AC 301 ms
79,476 KB
testcase_16 AC 352 ms
80,696 KB
testcase_17 AC 366 ms
79,484 KB
testcase_18 AC 339 ms
79,484 KB
testcase_19 AC 345 ms
227,224 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (103 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 map = NArr(n);
        var a = NList;
        WriteLine(AinS(n, m, map, a));
    }
    static string AinS(int n, int m, int[][] map, int[] a)
    {
        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 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[100001];
        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])
                    {
                        ++ans[j];
                    }
                }
            }
        }
        for (var i = 1; i < tbl.Length; ++i)
        {
            if (tbl[i].Count == 0) continue;
            tbl[i].Sort((l, r) => l.time.CompareTo(r.time));
            var count = new int[i];
            var pos = 0;
            for (var j = 1; j < 100001; ++j)
            {
                while (pos < tbl[i].Count && tbl[i][pos].time <= j)
                {
                    count[tbl[i][pos].y] += tbl[i][pos].flg;
                    ++pos;
                }
                ans[j] += count[j % i];
            }
        }
        return string.Join("\n", a.Select(ai => ans[ai]));
    }
}
0