結果

問題 No.2408 Lakes and Fish
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-08-11 22:48:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 309 ms / 2,000 ms
コード長 515 bytes
コンパイル時間 2,262 ms
コンパイル使用メモリ 208,988 KB
実行使用メモリ 12,800 KB
最終ジャッジ日時 2024-04-29 13:56:22
合計ジャッジ時間 6,856 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 223 ms
12,672 KB
testcase_05 AC 222 ms
12,800 KB
testcase_06 AC 222 ms
12,672 KB
testcase_07 AC 307 ms
12,800 KB
testcase_08 AC 305 ms
12,800 KB
testcase_09 AC 309 ms
12,672 KB
testcase_10 AC 307 ms
12,800 KB
testcase_11 AC 129 ms
6,656 KB
testcase_12 AC 214 ms
10,880 KB
testcase_13 AC 52 ms
5,760 KB
testcase_14 AC 105 ms
6,784 KB
testcase_15 AC 227 ms
9,728 KB
testcase_16 AC 87 ms
8,064 KB
testcase_17 AC 52 ms
5,376 KB
testcase_18 AC 139 ms
9,472 KB
testcase_19 AC 195 ms
8,192 KB
testcase_20 AC 140 ms
5,376 KB
testcase_21 AC 214 ms
8,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main () {
	int N, M;
	cin >> N >> M;
	ll ans = 0;
	set<ll> st1; set<ll, greater<ll>> st2;
	for (int i = 0; i < N; i ++) {
		ll L;
		cin >> L;
		st1.insert(L); st2.insert(L);
	}
	st1.insert((ll)1e14);
	st2.insert(-(ll)1e14);
	for (int i = 0; i < M; i ++) {
		ll f, b, w;
		cin >> f >> b >> w;
		ans += b;
		ll df = w - b;
		df -= min(abs(f - *st1.lower_bound(f)), abs(f - *st2.lower_bound(f)));
		ans += max(0ll, df);
	}
	cout << ans << endl;
}
0