結果

問題 No.2408 Lakes and Fish
ユーザー vjudge1vjudge1
提出日時 2024-05-01 22:21:21
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 789 bytes
コンパイル時間 3,113 ms
コンパイル使用メモリ 246,384 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-22 05:33:41
合計ジャッジ時間 6,752 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 2 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#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];
    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;
}
0