結果

問題 No.2408 Lakes and Fish
ユーザー inkyamaninkyaman
提出日時 2024-03-25 20:56:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 788 bytes
コンパイル時間 1,071 ms
コンパイル使用メモリ 116,644 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-25 20:56:41
合計ジャッジ時間 5,528 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 1 ms
6,548 KB
testcase_04 AC 154 ms
6,548 KB
testcase_05 AC 154 ms
6,548 KB
testcase_06 AC 146 ms
6,548 KB
testcase_07 AC 172 ms
6,548 KB
testcase_08 AC 172 ms
6,548 KB
testcase_09 AC 173 ms
6,548 KB
testcase_10 AC 196 ms
6,548 KB
testcase_11 AC 90 ms
6,548 KB
testcase_12 AC 123 ms
6,548 KB
testcase_13 AC 34 ms
6,548 KB
testcase_14 AC 71 ms
6,548 KB
testcase_15 AC 138 ms
6,548 KB
testcase_16 AC 48 ms
6,548 KB
testcase_17 AC 39 ms
6,548 KB
testcase_18 AC 82 ms
6,548 KB
testcase_19 AC 132 ms
6,548 KB
testcase_20 AC 133 ms
6,548 KB
testcase_21 AC 136 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
#include <tuple>
using namespace std;
using ll = long long;

int N, M;
ll L[101010];

int main() {

    cin >> N >> M;
    for(int i = 0; i < N; ++i) cin >> L[i];

    ll ans = 0;
    for(int i = 0; i < M; ++i) {
        int F; ll B, W; cin >> F >> B >> W;
        int n = lower_bound(L, L+N, F)-L;
        int c;
        if(n == N) c = F-L[N-1];
        else if(n == 0) c = L[0]-F;
        else c = min(L[n]-F, F-L[n-1]);

        ans += max(B, W-c);
    }

    cout << ans << endl;

}

0