結果
問題 | No.2408 Lakes and Fish |
ユーザー |
![]() |
提出日時 | 2023-08-11 21:38:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 179 ms / 2,000 ms |
コード長 | 449 bytes |
コンパイル時間 | 1,780 ms |
コンパイル使用メモリ | 196,048 KB |
最終ジャッジ日時 | 2025-02-16 01:10:30 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define int long longsigned main(){int N,Q;cin>>N>>Q;int ans = 0;vector<int> S(N);for(int i=0;i<N;i++) cin>>S[i];while(Q--){int a,b,c;cin>>a>>b>>c;c -= b;int m = 1e18;auto it = lower_bound(S.begin(),S.end(),a);if(it != S.end()) m = min(m,(*it)-a);if(it != S.begin()){it--;m = min(m,a-(*it));}if(m < c) ans += c+b-m;else ans += b;}cout<<ans<<endl;}