結果
| 問題 | No.2408 Lakes and Fish | 
| コンテスト | |
| ユーザー |  vjudge1 | 
| 提出日時 | 2024-05-01 11:21:24 | 
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 126 ms / 2,000 ms | 
| コード長 | 854 bytes | 
| コンパイル時間 | 7,212 ms | 
| コンパイル使用メモリ | 163,864 KB | 
| 実行使用メモリ | 8,064 KB | 
| 最終ジャッジ日時 | 2024-11-21 15:19:27 | 
| 合計ジャッジ時間 | 10,227 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define sec second
#define pairz pair<ll,ll>
#define pb push_back
ll tc = 1;
const ll INF = 1e18;
const ll N = 1e6+5;
const ll MOD = 1e9 + 7;
 
// thy will, not mine, be done.
void input(){
	ll n,m; cin >> n >> m;
	set<ll>st;
	for(int i=1;i<=n;i++){
		ll x; cin >> x;
		st.insert(x);
	}
	ll ans = 0;
	for(int i=1;i<=m;i++){
		ll f,b,w; cin >> f >> b >> w;
		auto x = st.lower_bound(f);
		auto y = x;
		if(x == st.end()) --y;
		if(x != st.begin()) --x;
		if(*y == f) ans += w;
		else{
			ans += max({b, w - abs(f - *y), w - abs(f - *x)});
		}
	}
	cout << ans << endl;
}	
 
int main(){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
   	// cin >> tc;
    while(tc--) input();
}
/*
usahain clean code, jangan ribet2 implementasinya
11 + 14 + 8 = 33
2023 - 2013 2
*/
            
            
            
        