結果

問題 No.2408 Lakes and Fish
ユーザー SSRSSSRS
提出日時 2023-08-11 21:23:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 498 bytes
コンパイル時間 1,628 ms
コンパイル使用メモリ 168,396 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 12:11:54
合計ジャッジ時間 5,157 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 157 ms
5,376 KB
testcase_05 AC 158 ms
5,376 KB
testcase_06 AC 148 ms
5,376 KB
testcase_07 AC 173 ms
5,376 KB
testcase_08 AC 173 ms
5,376 KB
testcase_09 AC 172 ms
5,376 KB
testcase_10 AC 172 ms
5,376 KB
testcase_11 AC 90 ms
5,376 KB
testcase_12 AC 124 ms
5,376 KB
testcase_13 AC 34 ms
5,376 KB
testcase_14 AC 71 ms
5,376 KB
testcase_15 AC 139 ms
5,376 KB
testcase_16 AC 49 ms
5,376 KB
testcase_17 AC 39 ms
5,376 KB
testcase_18 AC 83 ms
5,376 KB
testcase_19 AC 132 ms
5,376 KB
testcase_20 AC 131 ms
5,376 KB
testcase_21 AC 137 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0