結果
問題 | No.2408 Lakes and Fish |
ユーザー |
![]() |
提出日時 | 2023-08-11 21:24:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 187 ms / 2,000 ms |
コード長 | 665 bytes |
コンパイル時間 | 717 ms |
コンパイル使用メモリ | 75,900 KB |
最終ジャッジ日時 | 2025-02-16 00:58:16 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <vector>#include <iostream>#include <algorithm>using namespace std;int main() {int N, M;cin >> N >> M;vector<long long> L(N);for (int i = 0; i < N; i++) {cin >> L[i];}vector<long long> F(M), B(M), W(M);for (int i = 0; i < M; i++) {cin >> F[i] >> B[i] >> W[i];}long long answer = 0;for (int i = 0; i < M; i++) {int pos = lower_bound(L.begin(), L.end(), F[i]) - L.begin();long long subanswer = B[i];if (pos != N) {subanswer = max(subanswer, W[i] - (L[pos] - F[i]));}if (pos != 0) {subanswer = max(subanswer, W[i] - (F[i] - L[pos - 1]));}answer += subanswer;}cout << answer << endl;return 0;}