結果
| 問題 | No.2408 Lakes and Fish | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-08-11 21:27:21 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 61 ms / 2,000 ms | 
| コード長 | 775 bytes | 
| コンパイル時間 | 2,189 ms | 
| コンパイル使用メモリ | 196,040 KB | 
| 最終ジャッジ日時 | 2025-02-16 01:01:56 | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 | 
ソースコード
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include "bits/stdc++.h"
using namespace std;
using ll = long long int;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    vector<int> pos(n);
    for (int &x : pos) cin >> x;
    ll ans = 0;
    for (int i = 0; i < m; ++i) {
        int y, a, b; cin >> y >> a >> b;
        auto it = lower_bound(begin(pos), end(pos), y);
        int add = a;
        if (it != end(pos)) add = max(add, b - (*it - y));
        if (it != begin(pos)) {
            --it;
            add = max(add, b - (y - *it));
        }
        ans +=add;
    }
    cout << ans << '\n';
}
            
            
            
        