結果
| 問題 | No.2408 Lakes and Fish |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-01 22:24:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 817 bytes |
| 記録 | |
| コンパイル時間 | 2,064 ms |
| コンパイル使用メモリ | 172,064 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-22 05:37:30 |
| 合計ジャッジ時間 | 5,221 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 WA * 17 |
ソースコード
#include<bits/stdc++.h>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
const ll M = 1e9+7;
int main() {
ll n,m,ans=0,r=0;cin >> m >> n;vector <ll> arr(m);
for (ll i = 0; i < m; i++)cin >> arr[i];sort(arr.begin(),arr.end());
while(n--){
ll cor,a,b;cin >> cor >> a >> b;
ll it=lower_bound(arr.begin(),arr.end(),cor)-arr.begin();
if(arr[it]==cor)ans+=b;
else if(it==0){
if(arr[it]-cor<b-a)ans+=b-(arr[it]-cor);
else ans+=a;
}else if(it==m){
if(cor-arr[it-1]<b-a)ans+=b-(cor-arr[it-1]);
else ans+=a;
}else{
if(arr[it]-cor<b-a)ans+=b-(arr[it]-cor);
else if(cor-arr[it-1]<b-a)ans+=b-(cor-arr[it-1]);
else ans+=a;
}
}cout << ans;
}