結果
問題 | No.2408 Lakes and Fish |
ユーザー |
|
提出日時 | 2024-10-27 16:01:22 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 177 ms / 2,000 ms |
コード長 | 802 bytes |
コンパイル時間 | 2,363 ms |
コンパイル使用メモリ | 203,588 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-27 16:01:29 |
合計ジャッジ時間 | 7,295 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;#define rep(i, s, e) for (int i = (int)s; i < (int)e; ++i)#define all(a) (a).begin(), (a).end()int main() {cin.tie(nullptr);int N, M;cin >> N >> M;vector<ll> L(N), F(M), B(M), W(M);rep(i, 0, N) cin >> L[i];rep(i, 0, M) cin >> F[i] >> B[i] >> W[i];ll ans = 0;rep(i, 0, M) {if (binary_search(all(L), F[i])) {ans += W[i];continue;}int ind = lower_bound(all(L), F[i]) - L.begin();ll left = LLONG_MAX, right = LLONG_MAX;if (ind != N) right = L[ind] - F[i];if (ind != 0) left = F[i] - L[ind - 1];ans += max(B[i], W[i] - min(right, left));}cout << ans << '\n';}