結果
問題 | No.2408 Lakes and Fish |
ユーザー |
|
提出日時 | 2024-03-03 18:43:17 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 127 ms / 2,000 ms |
コード長 | 761 bytes |
コンパイル時間 | 23,256 ms |
コンパイル使用メモリ | 352,756 KB |
最終ジャッジ日時 | 2025-02-20 00:18:00 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include<bits/stdc++.h> #include<atcoder/all> using namespace std; using namespace atcoder; using ll=long long; void IO(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); } int main(){ IO(); ll n,m; cin>>n>>m; vector<ll> l(n+2); l[0]=-1e18; for(ll i=1;i<=n;i++){ cin>>l[i]; } l[n+1]=1e18; vector<ll> f(m),b(m),w(m); for(ll i=0;i<m;i++){ cin>>f[i]>>b[i]>>w[i]; } ll ans=0; for(ll i=0;i<m;i++){ auto itr=lower_bound(l.begin(),l.end(),f[i]); ll vl=*itr; ll vr=*prev(itr); ll tmp=min(abs(vl-f[i]),abs(vr-f[i])); if(b[i]<w[i]-tmp){ ans+=w[i]-tmp; }else{ ans+=b[i]; } } cout<<ans<<endl; }