結果
問題 |
No.2408 Lakes and Fish
|
ユーザー |
![]() |
提出日時 | 2024-05-01 22:18:21 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 116 ms / 2,000 ms |
コード長 | 645 bytes |
コンパイル時間 | 3,849 ms |
コンパイル使用メモリ | 277,304 KB |
実行使用メモリ | 8,320 KB |
最終ジャッジ日時 | 2024-11-22 05:29:08 |
合計ジャッジ時間 | 5,980 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
// Source: https://usaco.guide/general/io #include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int times = 1; while(times--){ ll n, m; cin >> n >> m; set <ll> s; for(int i = 0 ; i < n ; i++){ ll temp; cin >> temp; s.insert(temp); } ll answer = 0; for(int i = 0 ; i < m ; i++){ ll f, b, w; cin >> f >> b >> w; auto e = s.lower_bound(f); auto r = e; if(e == s.end()) r--; if(e != s.begin()) e--; if(*r == f) answer += w; else answer += max(b, max(w - abs(f - *r), w - abs(f - *e))); } cout << answer << endl; } }