結果
| 問題 | No.2408 Lakes and Fish | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-08-25 16:58:34 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 64 ms / 2,000 ms | 
| コード長 | 546 bytes | 
| コンパイル時間 | 1,777 ms | 
| コンパイル使用メモリ | 166,296 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-24 02:13:13 | 
| 合計ジャッジ時間 | 4,896 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,m;
	cin>>n>>m;
	ll arr[n];
	for(auto &i:arr)cin>>i;
	ll ans = 0;
	for(int i = 0;i<m;i++){
		ll a,b,c;
		cin>>a>>b>>c;
		ll pos = lower_bound(arr,arr+n,a)-arr;
		ll tmp = b;
		if(pos != n)tmp = max(tmp,c-(arr[pos]-a));
		if(pos != 0)tmp = max(tmp,c-(a-arr[pos-1]));
		ans += tmp;
	}
	cout<<ans;
}
            
            
            
        