結果

問題 No.2408 Lakes and Fish
ユーザー cho435cho435
提出日時 2023-08-11 23:16:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 605 bytes
コンパイル時間 1,804 ms
コンパイル使用メモリ 204,548 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 14:26:13
合計ジャッジ時間 5,125 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 146 ms
5,376 KB
testcase_05 AC 144 ms
5,376 KB
testcase_06 AC 136 ms
5,376 KB
testcase_07 AC 170 ms
5,376 KB
testcase_08 AC 165 ms
5,376 KB
testcase_09 AC 168 ms
5,376 KB
testcase_10 AC 169 ms
5,376 KB
testcase_11 AC 85 ms
5,376 KB
testcase_12 AC 116 ms
5,376 KB
testcase_13 AC 33 ms
5,376 KB
testcase_14 AC 69 ms
5,376 KB
testcase_15 AC 136 ms
5,376 KB
testcase_16 AC 44 ms
5,376 KB
testcase_17 AC 36 ms
5,376 KB
testcase_18 AC 80 ms
5,376 KB
testcase_19 AC 125 ms
5,376 KB
testcase_20 AC 126 ms
5,376 KB
testcase_21 AC 131 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0