結果

問題 No.2408 Lakes and Fish
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-08-24 11:24:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 234 ms / 2,000 ms
コード長 595 bytes
コンパイル時間 2,837 ms
コンパイル使用メモリ 205,600 KB
実行使用メモリ 8,292 KB
最終ジャッジ日時 2023-08-24 11:24:36
合計ジャッジ時間 8,120 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 185 ms
8,104 KB
testcase_05 AC 184 ms
8,052 KB
testcase_06 AC 174 ms
7,988 KB
testcase_07 AC 228 ms
8,048 KB
testcase_08 AC 230 ms
8,272 KB
testcase_09 AC 230 ms
8,292 KB
testcase_10 AC 234 ms
8,048 KB
testcase_11 AC 106 ms
5,004 KB
testcase_12 AC 164 ms
7,128 KB
testcase_13 AC 42 ms
4,612 KB
testcase_14 AC 86 ms
5,080 KB
testcase_15 AC 181 ms
6,492 KB
testcase_16 AC 65 ms
5,748 KB
testcase_17 AC 44 ms
4,376 KB
testcase_18 AC 110 ms
6,364 KB
testcase_19 AC 160 ms
5,736 KB
testcase_20 AC 133 ms
4,380 KB
testcase_21 AC 170 ms
5,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){

    ll N, M, ans=0, L;
    cin >> N >> M;
    set<ll> st;
    st.insert(1e18);
    st.insert(-1e18);
    for (int i=1; i<=N; i++){
        cin >> L;
        st.insert(L);
    }

    ll F, W, B;

    for (int i=0; i<M; i++){
        cin >> F >> B >> W;
        if (st.count(F)) ans += W;
        else{
            auto it = st.lower_bound(F);
            ll mi = *it-F;
            it--;
            mi = min(F-*it, mi);
            ans += max(W-mi, B);
        }
    }

    cout << ans << endl;

    return 0;
}
0