結果
| 問題 | No.2408 Lakes and Fish | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-08-11 21:25:16 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 62 ms / 2,000 ms | 
| コード長 | 423 bytes | 
| コンパイル時間 | 552 ms | 
| コンパイル使用メモリ | 67,604 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-18 15:22:06 | 
| 合計ジャッジ時間 | 2,417 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 | 
ソースコード
#include<iostream>
#include<algorithm>
#include<cassert>
using namespace std;
int N,M;
int L[1<<17];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>N>>M;
	for(int i=0;i<N;i++)cin>>L[i];
	long ans=0;
	for(int i=0;i<M;i++)
	{
		int F,B,W;cin>>F>>B>>W;
		int id=lower_bound(L,L+N,F)-L;
		int mn=2e9;
		if(id<N)mn=min(mn,L[id]-F);
		if(id>0)mn=min(mn,F-L[id-1]);
		ans+=max(B,W-mn);
	}
	cout<<ans<<endl;
}
            
            
            
        