結果
| 問題 |
No.2408 Lakes and Fish
|
| コンテスト | |
| ユーザー |
PAKACHU
|
| 提出日時 | 2023-08-11 21:57:05 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 170 ms / 2,000 ms |
| コード長 | 853 bytes |
| コンパイル時間 | 2,348 ms |
| コンパイル使用メモリ | 164,808 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-18 16:11:56 |
| 合計ジャッジ時間 | 5,834 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
int dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const long long mod = 998244353;
const ll inf = 1LL << 60;
const int INF = 5e8;
int main()
{
int n, m;
cin >> n >> m;
vector<int> l(n);
for (int i = 0; i < n; i++)
cin >> l[i];
ll ans = 0;
for (int i = 0; i < m; i++) {
int f, b, w;
cin >> f >> b >> w;
auto it = lower_bound(l.begin(), l.end(), f);
if (it == l.begin()) {
ans += max(b, -(l[0] - f) + w);
} else if (it == l.end()) {
ans += max(b, -(f - l[n - 1]) + w);
} else {
ans += max({ b, -(*it - f) + w, -(f - *prev(it)) + w });
}
}
cout << ans << endl;
}
PAKACHU