結果
| 問題 | No.2408 Lakes and Fish | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-08-11 21:42:40 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 242 ms / 2,000 ms | 
| コード長 | 1,341 bytes | 
| コンパイル時間 | 884 ms | 
| コンパイル使用メモリ | 115,304 KB | 
| 実行使用メモリ | 46,808 KB | 
| 最終ジャッジ日時 | 2024-11-18 15:42:53 | 
| 合計ジャッジ時間 | 5,991 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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;
    }
}
            
            
            
        