結果

問題 No.2408 Lakes and Fish
ユーザー VincentVincent
提出日時 2024-05-01 22:44:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 220 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 1,848 ms
コンパイル使用メモリ 171,484 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2024-05-01 22:44:53
合計ジャッジ時間 5,541 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 172 ms
8,192 KB
testcase_05 AC 167 ms
8,064 KB
testcase_06 AC 170 ms
8,064 KB
testcase_07 AC 220 ms
8,192 KB
testcase_08 AC 209 ms
8,064 KB
testcase_09 AC 203 ms
8,192 KB
testcase_10 AC 204 ms
8,192 KB
testcase_11 AC 93 ms
5,376 KB
testcase_12 AC 146 ms
7,168 KB
testcase_13 AC 37 ms
5,376 KB
testcase_14 AC 76 ms
5,376 KB
testcase_15 AC 176 ms
6,656 KB
testcase_16 AC 58 ms
5,760 KB
testcase_17 AC 41 ms
5,376 KB
testcase_18 AC 94 ms
6,528 KB
testcase_19 AC 144 ms
5,888 KB
testcase_20 AC 117 ms
5,376 KB
testcase_21 AC 147 ms
6,016 KB
権限があれば一括ダウンロードができます

ソースコード

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;cin >> m >> n;set <ll> arr;
    for (ll i = 0; i < m; i++){ll a;cin >> a;arr.insert(a);}
    while(n--){
        ll cor,a,b;cin >> cor >> a >> b;
        auto it=arr.lower_bound(cor);
        if(it==arr.end())it--;
        auto _it=it;
        if(it!=arr.begin())_it--;
        if(*it==cor)ans+=b;
        else ans+=max({a,b-abs(cor-*_it),b-abs(*it-cor)});
    }cout << ans;
}
0