結果
| 問題 | No.2408 Lakes and Fish |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2024-05-01 22:17:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 127 ms / 2,000 ms |
| コード長 | 1,071 bytes |
| 記録 | |
| コンパイル時間 | 4,022 ms |
| コンパイル使用メモリ | 201,648 KB |
| 最終ジャッジ日時 | 2025-02-21 10:05:24 |
|
ジャッジサーバー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();
// }
}
vjudge1