結果
| 問題 | No.2408 Lakes and Fish | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-08-11 23:16:17 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 212 ms / 2,000 ms | 
| コード長 | 605 bytes | 
| コンパイル時間 | 1,965 ms | 
| コンパイル使用メモリ | 196,472 KB | 
| 最終ジャッジ日時 | 2025-02-16 02:06:06 | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(){
	int n,m;
	cin>>n>>m;
	vector<int> l(n);
	rep(i,n) cin>>l.at(i);
	vector<int> f(m),b(m),w(m);
	rep(i,m) cin>>f.at(i)>>b.at(i)>>w.at(i);
	ll ans=0;
	rep(i,m){
		if(!binary_search(l.begin(),l.end(),f.at(i))){
			auto itr=lower_bound(l.begin(),l.end(),f.at(i));
			int tmp=1e9;
			if(itr!=l.end()) tmp=min(tmp,*itr-f.at(i));
			if(itr!=l.begin()){
				itr--;
				tmp=min(tmp,f.at(i)-*itr);
			}
			ans+=max(b.at(i),w.at(i)-tmp);
		}else{
			ans+=w.at(i);
		}
	}
	cout<<ans<<endl;
}
            
            
            
        