結果
| 問題 | No.2408 Lakes and Fish | 
| コンテスト | |
| ユーザー |  vjudge1 | 
| 提出日時 | 2024-05-01 11:48:52 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 66 ms / 2,000 ms | 
| コード長 | 1,012 bytes | 
| コンパイル時間 | 1,956 ms | 
| コンパイル使用メモリ | 197,520 KB | 
| 最終ジャッジ日時 | 2025-02-21 10:01:18 | 
| ジャッジサーバーID (参考情報) | judge4 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define ppb pop_back
#define mp make_pair 
#define fi first
#define se second
#define endl '\n'
const int mod = 1e9+7;
void solve(){
    int n, m;
    cin >> n >> m;
    int pohon[n];
    for (int i = 0; i < n; i++){
        cin >> pohon[i];
    }
    vector<tuple<int, int, int>> ikan;
    for (int i = 0; i < m; i++){
        int a, b, c;
        cin >> a >> b >> c;
        ikan.pb(make_tuple(a, b, c));
    }
    int ans = 0;
    for (auto i:ikan){
        int f = get<0> (i);
        int b = get<1> (i);
        int w = get<2> (i);
        int y = upper_bound(pohon, pohon+n, f)-pohon;
        if (y > n-1) y = n-1;
        int x = y-1;
        if (x < 0) x = 0;
        w = max(w-abs(f-pohon[x]), w-abs(f-pohon[y]));
        ans += max(b, w);
    }
    cout << ans << endl;
}
signed main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1; //cin >> t;
    while (t--){
        solve();
    }
}
            
            
            
        