結果

問題 No.2408 Lakes and Fish
ユーザー 👑 kakel-sankakel-san
提出日時 2023-08-11 21:42:40
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 276 ms / 2,000 ms
コード長 1,341 bytes
コンパイル時間 913 ms
コンパイル使用メモリ 107,520 KB
実行使用メモリ 38,656 KB
最終ジャッジ日時 2024-04-29 12:33:45
合計ジャッジ時間 6,016 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
19,200 KB
testcase_01 AC 30 ms
19,200 KB
testcase_02 AC 30 ms
19,200 KB
testcase_03 AC 30 ms
19,200 KB
testcase_04 AC 259 ms
37,504 KB
testcase_05 AC 253 ms
37,504 KB
testcase_06 AC 254 ms
36,224 KB
testcase_07 AC 271 ms
38,656 KB
testcase_08 AC 272 ms
38,656 KB
testcase_09 AC 274 ms
38,528 KB
testcase_10 AC 276 ms
38,528 KB
testcase_11 AC 163 ms
30,080 KB
testcase_12 AC 202 ms
34,816 KB
testcase_13 AC 82 ms
26,624 KB
testcase_14 AC 135 ms
29,312 KB
testcase_15 AC 229 ms
34,944 KB
testcase_16 AC 100 ms
29,312 KB
testcase_17 AC 90 ms
25,856 KB
testcase_18 AC 147 ms
31,488 KB
testcase_19 AC 219 ms
32,768 KB
testcase_20 AC 224 ms
28,800 KB
testcase_21 AC 227 ms
33,536 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

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