結果
問題 | No.2408 Lakes and Fish |
ユーザー |
![]() |
提出日時 | 2024-05-01 22:17:15 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 104 ms / 2,000 ms |
コード長 | 1,071 bytes |
コンパイル時間 | 2,055 ms |
コンパイル使用メモリ | 206,988 KB |
実行使用メモリ | 8,960 KB |
最終ジャッジ日時 | 2024-11-22 05:25:51 |
合計ジャッジ時間 | 4,447 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") typedef long long ll; const ll INF = 1e18; const ll MOD = 1e9 + 7; const ll MAXN = 2e5 + 5; const ll LOG = 100; #define vll vector <ll> #define pll pair <ll, ll> #define fi first #define se second #define endl '\n' ll n, m; ll a [MAXN]; set <ll> st; pll b [MAXN]; void solve(){ cin >> n >> m; st.clear(); for(ll i = 1; i <= n; i++){ cin >> a[i]; st.insert(a[i]); } ll tot = 0; for(ll i = 1; i <= m; i++){ ll x, y, z; cin >> x >> y >> z; ll mn = INF; auto it = st.lower_bound(x); if(it != st.end()){ mn = min(mn, abs(*it - x)); } if(it != st.begin()){ it = prev(it); mn = min(mn, abs(*it - x)); } tot += y + max((ll)0, z-y-mn); } cout << tot << endl; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // ll t; // cin >> t; // while(t--){ solve(); // } }