結果

問題 No.2408 Lakes and Fish
ユーザー yutake2000yutake2000
提出日時 2023-08-11 21:39:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 1,433 bytes
コンパイル時間 2,093 ms
コンパイル使用メモリ 202,892 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 12:30:42
合計ジャッジ時間 5,549 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pdd;
template<typename T>
using MaxHeap = priority_queue<T>;
template<typename T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define INF (ll)1e17
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define cauto const auto&
#define cdebug if (debug_mode) cerr
#define dump(x) if (debug_mode) cerr << #x << " = " << (x) << "\t";
#define SP << " " <<
#define TB << "\t" <<

#ifdef _LOCAL
    bool debug_mode = true;
#else
    bool debug_mode = false;
#endif

int main()
{

    ll N, M;
    cin >> N >> M;
    vector<ll> L(N);
    REP(i, N) cin >> L[i];

    ll ans = 0;
    REP(i, M) {
        ll pos, b, w;
        cin >> pos >> b >> w;
        ll s = b;
        auto itr = lower_bound(ALL(L), pos);
        // cdebug << *prev(itr) << endl;
        if (itr != L.end()) {
            s = max(s, w - abs(*itr - pos));
        }
        if (itr != L.begin()) {
            s = max(s, w - abs(*prev(itr) - pos));
        }
        ans += s;
    }

    cout << ans << endl;

    return 0;
}
0