結果
| 問題 | No.2408 Lakes and Fish | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-08-11 21:25:44 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 58 ms / 2,000 ms | 
| コード長 | 598 bytes | 
| コンパイル時間 | 1,716 ms | 
| コンパイル使用メモリ | 193,772 KB | 
| 最終ジャッジ日時 | 2025-02-16 00:59:21 | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define all(a) a.begin(),a.end()
#define pb push_back
#define sz(a) ((int)a.size())
const int N=100005;
int n,m,a[N];
signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n >> m;
    for(int i=0; i<n; ++i) cin >> a[i];
    ll res=0;
    for(int i=0; i<m; ++i){
        int f,b,w,mn=2e9; cin >> f >> b >> w;
        int j=lower_bound(a,a+n,f)-a;
        if(j<n) mn=min(mn,a[j]-f);
        j--;
        if(j>=0) mn=min(mn,f-a[j]);
        res+=max(b,w-mn);
    }
    cout << res << "\n";
}
            
            
            
        