結果
問題 | No.2408 Lakes and Fish |
ユーザー | Today03 |
提出日時 | 2023-08-11 21:44:12 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 58 ms / 2,000 ms |
コード長 | 700 bytes |
コンパイル時間 | 2,254 ms |
コンパイル使用メモリ | 208,180 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 15:45:49 |
合計ジャッジ時間 | 4,254 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n,m; cin>>n>>m; vector<long long> l(n),f(m),b(m),w(m); for (int i=0;i<n;i++) cin>>l[i]; for (int i=0;i<m;i++) cin>>f[i]>>b[i]>>w[i]; sort(l.begin(),l.end()); long long ans=0; for (int i=0;i<m;i++) { int idx=lower_bound(l.begin(),l.end(),f[i])-l.begin(); if (idx==n) idx--; if (l[idx]==f[i]) { ans+=w[i]; continue; } long long res=b[i]; long long get=w[i]-abs(l[idx]-f[i]); res=max(res,get); if (idx>0) { idx--; long long get2=w[i]-abs(f[i]-l[idx]); res=max(res,get2); } ans+=res; } cout<<ans<<endl; }