結果

問題 No.2408 Lakes and Fish
ユーザー keisuke6keisuke6
提出日時 2023-08-11 21:38:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 174 ms / 2,000 ms
コード長 449 bytes
コンパイル時間 2,096 ms
コンパイル使用メモリ 202,728 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 12:29:31
合計ジャッジ時間 5,486 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 152 ms
5,376 KB
testcase_05 AC 152 ms
5,376 KB
testcase_06 AC 144 ms
5,376 KB
testcase_07 AC 171 ms
5,376 KB
testcase_08 AC 174 ms
5,376 KB
testcase_09 AC 172 ms
5,376 KB
testcase_10 AC 171 ms
5,376 KB
testcase_11 AC 90 ms
5,376 KB
testcase_12 AC 124 ms
5,376 KB
testcase_13 AC 34 ms
5,376 KB
testcase_14 AC 71 ms
5,376 KB
testcase_15 AC 137 ms
5,376 KB
testcase_16 AC 48 ms
5,376 KB
testcase_17 AC 38 ms
5,376 KB
testcase_18 AC 82 ms
5,376 KB
testcase_19 AC 131 ms
5,376 KB
testcase_20 AC 128 ms
5,376 KB
testcase_21 AC 134 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	int N,Q;
	cin>>N>>Q;
	int ans = 0;
	vector<int> S(N);
	for(int i=0;i<N;i++) cin>>S[i];
	while(Q--){
		int a,b,c;
		cin>>a>>b>>c;
		c -= b;
		int m = 1e18;
		auto it = lower_bound(S.begin(),S.end(),a);
		if(it != S.end()) m = min(m,(*it)-a);
		if(it != S.begin()){
			it--;
			m = min(m,a-(*it));
		}
		if(m < c) ans += c+b-m;
		else ans += b;
	}
	cout<<ans<<endl;
}
0