結果

問題 No.2408 Lakes and Fish
ユーザー 👑 kakel-sankakel-san
提出日時 2023-08-11 21:42:40
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 293 ms / 2,000 ms
コード長 1,341 bytes
コンパイル時間 931 ms
コンパイル使用メモリ 66,496 KB
実行使用メモリ 43,012 KB
最終ジャッジ日時 2023-08-11 21:42:49
合計ジャッジ時間 6,984 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
19,964 KB
testcase_01 AC 62 ms
19,944 KB
testcase_02 AC 62 ms
19,960 KB
testcase_03 AC 63 ms
21,868 KB
testcase_04 AC 269 ms
41,900 KB
testcase_05 AC 270 ms
42,048 KB
testcase_06 AC 270 ms
40,780 KB
testcase_07 AC 293 ms
43,012 KB
testcase_08 AC 289 ms
38,904 KB
testcase_09 AC 288 ms
41,068 KB
testcase_10 AC 291 ms
41,064 KB
testcase_11 AC 189 ms
32,180 KB
testcase_12 AC 230 ms
35,464 KB
testcase_13 AC 113 ms
28,900 KB
testcase_14 AC 162 ms
33,768 KB
testcase_15 AC 247 ms
39,088 KB
testcase_16 AC 129 ms
29,624 KB
testcase_17 AC 119 ms
28,512 KB
testcase_18 AC 177 ms
34,028 KB
testcase_19 AC 240 ms
35,208 KB
testcase_20 AC 238 ms
35,284 KB
testcase_21 AC 244 ms
35,620 KB
権限があれば一括ダウンロードができます

ソースコード

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 l = NList;
        var map = NArr(m);
        var ans = 0L;
        for (var i = 0; i < map.Length; ++i)
        {
            var pos = LowerBound(0, map[i][0], l);
            if (pos == l.Length) --pos;
            else if (pos > 0)
            {
                if (map[i][0] - l[pos - 1] < l[pos] - map[i][0]) --pos;
            }
            ans += Math.Max(map[i][1], map[i][2] - Math.Abs(map[i][0] - l[pos]));
        }
        WriteLine(ans);
    }
    static int LowerBound(int left, int min, int[] list)
    {
        if (list[left] >= min) return left;
        var ng = left;
        var ok = list.Length;
        while (ok - ng > 1)
        {
            var center = (ng + ok) / 2;
            if (list[center] < min) ng = center;
            else ok = center;
        }
        return ok;
    }
}
0