結果

問題 No.2408 Lakes and Fish
ユーザー hatsuka_iwahatsuka_iwa
提出日時 2023-09-05 18:14:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 161 ms / 2,000 ms
コード長 494 bytes
コンパイル時間 1,662 ms
コンパイル使用メモリ 167,620 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 18:14:33
合計ジャッジ時間 5,638 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 141 ms
4,384 KB
testcase_05 AC 142 ms
4,376 KB
testcase_06 AC 134 ms
4,376 KB
testcase_07 AC 161 ms
4,380 KB
testcase_08 AC 159 ms
4,380 KB
testcase_09 AC 158 ms
4,380 KB
testcase_10 AC 158 ms
4,376 KB
testcase_11 AC 84 ms
4,376 KB
testcase_12 AC 114 ms
4,376 KB
testcase_13 AC 31 ms
4,376 KB
testcase_14 AC 66 ms
4,376 KB
testcase_15 AC 127 ms
4,376 KB
testcase_16 AC 44 ms
4,380 KB
testcase_17 AC 36 ms
4,380 KB
testcase_18 AC 76 ms
4,376 KB
testcase_19 AC 121 ms
4,376 KB
testcase_20 AC 119 ms
4,380 KB
testcase_21 AC 126 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M; cin >> N >> M;
  long long Ans = 0;
  vector<int> L(N); for (int &a : L) cin >> a;

  for (int i = 0; i < M; i++) {
    int F, B, W; cin >> F >> B >> W;
    int it = lower_bound(L.begin(), L.end(), F) - L.begin();
    if (it == 0) Ans += max(B, W - L.at(it) + F);
    else if (it == N) Ans += max(B, W - F + L.at(it - 1));
    else Ans += max(B, max( W - L.at(it) + F, W - F + L.at(it - 1)));
  }

  cout << Ans << endl;
}
0