結果

問題 No.2462 七人カノン
ユーザー bluemeganebluemegane
提出日時 2023-09-11 18:31:24
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 316 ms / 2,000 ms
コード長 1,299 bytes
コンパイル時間 2,031 ms
コンパイル使用メモリ 65,444 KB
実行使用メモリ 42,080 KB
最終ジャッジ日時 2023-09-11 18:31:39
合計ジャッジ時間 14,281 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
24,104 KB
testcase_01 AC 67 ms
26,136 KB
testcase_02 AC 68 ms
26,032 KB
testcase_03 AC 71 ms
26,144 KB
testcase_04 AC 72 ms
24,036 KB
testcase_05 AC 71 ms
24,136 KB
testcase_06 AC 71 ms
26,168 KB
testcase_07 AC 70 ms
24,224 KB
testcase_08 AC 72 ms
26,044 KB
testcase_09 AC 71 ms
23,884 KB
testcase_10 AC 73 ms
24,124 KB
testcase_11 AC 71 ms
22,116 KB
testcase_12 AC 71 ms
22,128 KB
testcase_13 AC 260 ms
38,508 KB
testcase_14 AC 275 ms
39,092 KB
testcase_15 AC 255 ms
38,376 KB
testcase_16 AC 301 ms
39,796 KB
testcase_17 AC 280 ms
37,636 KB
testcase_18 AC 109 ms
27,612 KB
testcase_19 AC 108 ms
27,672 KB
testcase_20 AC 305 ms
39,672 KB
testcase_21 AC 309 ms
39,748 KB
testcase_22 AC 308 ms
42,080 KB
testcase_23 AC 304 ms
39,780 KB
testcase_24 AC 224 ms
32,832 KB
testcase_25 AC 316 ms
40,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;

public class P
{
    public int id { get; set; }
    public int s { get; set; }
    public int t { get; set; }
}

public class Hello
{
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var q = int.Parse(line[1]);
        getAns(n, q);
    }
    static void getAns(int n, int q)
    {
        var ps = new P[q];
        var stmax = 100010;
        var map = new int[stmax];
        for (int i = 0; i < q; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]) - 1;
            var b = int.Parse(line[1]);
            var c = int.Parse(line[2]);
            map[b]++;
            map[c]--;
            ps[i] = new P { id = a, s = b, t = c };
        }
        for (int i = 1; i < stmax; i++) map[i] += map[i - 1];
        var map2 = new double[stmax];
        for (int i = 0; i < stmax; i++) map2[i] = map[i] == 0 ? 0 : 1d / map[i];
        var map3 = new double[stmax + 1];
        map3[0] = 0d;
        for (int i = 1; i < stmax + 1; i++) map3[i] = map3[i - 1] + map2[i - 1];
        var ans = new double[n];
        foreach (var x in ps) ans[x.id] += map3[x.t] - map3[x.s];
        Console.WriteLine(string.Join("\n", ans));
    }
}
0