結果
問題 |
No.2408 Lakes and Fish
|
ユーザー |
![]() |
提出日時 | 2024-07-09 14:56:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 62 ms / 2,000 ms |
コード長 | 713 bytes |
コンパイル時間 | 2,101 ms |
コンパイル使用メモリ | 195,536 KB |
最終ジャッジ日時 | 2025-02-22 02:36:07 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int n, m; cin >> n >> m; vector<int> l(n); for (int i = 0; i < n; i++) { cin >> l[i]; } long long ans = 0; for (int i = 0; i < m; i++) { int f; long long b, w; cin >> f >> b >> w; long long tmp = b; auto lb = lower_bound(l.begin(), l.end(), f); if (lb != l.end()) { tmp = max(tmp, w - (*lb - f)); } if (lb != l.begin()) { lb--; tmp = max(tmp, w - (f - *lb)); } ans += tmp; } cout << ans << endl; }