結果
| 問題 | No.2408 Lakes and Fish | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-08-14 09:32:55 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 65 ms / 2,000 ms | 
| コード長 | 567 bytes | 
| コンパイル時間 | 1,806 ms | 
| コンパイル使用メモリ | 168,468 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-22 05:11:40 | 
| 合計ジャッジ時間 | 4,762 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, F, B, W;
    cin >> n >> m;
    vector<int> L(n + 2);
    for(int i = 1; i <= n; i++) cin >> L[i];
    L.back() = (1ll << 31) - 1, L[0] = -(1 << 30);
    auto f = [&](int pos){
        int p = lower_bound(L.begin(), L.end(), pos) - L.begin();
        return min(L[p] - pos, pos - L[p - 1]);
    };
    ll ans = 0;
    while(m--){
        cin >> F >> B >> W;
        ans += max(B, W - f(F));
    }
    cout << ans << '\n';
}
            
            
            
        