結果
| 問題 | No.2408 Lakes and Fish | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-08-11 21:29:07 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 59 ms / 2,000 ms | 
| コード長 | 556 bytes | 
| コンパイル時間 | 1,992 ms | 
| コンパイル使用メモリ | 195,272 KB | 
| 最終ジャッジ日時 | 2025-02-16 01:03:03 | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0); cout.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> L(N);
  for(int i = 0; i < N; i++) {
    cin >> L[i];
  }
  long long ans = 0;
  while(M--) {
    int F, B, W;
    cin >> F >> B >> W;
    auto it = lower_bound(L.begin(), L.end(), F);
    int add = B;
    if(it != L.end()) {
      add = max(add, W - (*it - F));
    }
    if(it != L.begin()) {
      add = max(add, W - (F - *--it));
    }
    ans += add;
  }
  cout << ans << '\n';
  return 0;
}
            
            
            
        