結果
問題 | No.2408 Lakes and Fish |
ユーザー |
![]() |
提出日時 | 2024-03-25 20:56:36 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 173 ms / 2,000 ms |
コード長 | 788 bytes |
コンパイル時間 | 1,205 ms |
コンパイル使用メモリ | 115,796 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-09-30 14:08:36 |
合計ジャッジ時間 | 5,452 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#define _USE_MATH_DEFINES #include <iostream> #include <string> #include <algorithm> #include <vector> #include <queue> #include <math.h> #include <cmath> #include <stack> #include <map> #include <set> #include <numeric> #include <iomanip> #include <climits> #include <functional> #include <cassert> #include <tuple> using namespace std; using ll = long long; int N, M; ll L[101010]; int main() { cin >> N >> M; for(int i = 0; i < N; ++i) cin >> L[i]; ll ans = 0; for(int i = 0; i < M; ++i) { int F; ll B, W; cin >> F >> B >> W; int n = lower_bound(L, L+N, F)-L; int c; if(n == N) c = F-L[N-1]; else if(n == 0) c = L[0]-F; else c = min(L[n]-F, F-L[n-1]); ans += max(B, W-c); } cout << ans << endl; }