結果
問題 | No.2408 Lakes and Fish |
ユーザー |
![]() |
提出日時 | 2023-08-11 21:23:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 174 ms / 2,000 ms |
コード長 | 498 bytes |
コンパイル時間 | 1,681 ms |
コンパイル使用メモリ | 168,268 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 15:20:25 |
合計ジャッジ時間 | 5,084 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ 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, B, W; cin >> F >> B >> W; int p = lower_bound(L.begin(), L.end(), F) - L.begin(); int tmp = B; if (p >= 1){ tmp = max(tmp, W - (F - L[p - 1])); } if (p < N){ tmp = max(tmp, W - (L[p] - F)); } ans += tmp; } cout << ans << endl; }