結果

問題 No.2408 Lakes and Fish
ユーザー vjudge1vjudge1
提出日時 2024-05-01 22:37:26
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 598 bytes
コンパイル時間 3,619 ms
コンパイル使用メモリ 248,956 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2024-05-01 22:37:34
合計ジャッジ時間 7,840 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 189 ms
8,320 KB
testcase_05 AC 189 ms
8,192 KB
testcase_06 AC 179 ms
8,320 KB
testcase_07 AC 272 ms
8,192 KB
testcase_08 AC 244 ms
8,064 KB
testcase_09 AC 236 ms
8,064 KB
testcase_10 AC 267 ms
8,192 KB
testcase_11 AC 106 ms
5,376 KB
testcase_12 AC 165 ms
7,168 KB
testcase_13 AC 42 ms
5,376 KB
testcase_14 AC 86 ms
5,376 KB
testcase_15 AC 178 ms
6,656 KB
testcase_16 AC 65 ms
5,760 KB
testcase_17 AC 44 ms
5,376 KB
testcase_18 AC 110 ms
6,400 KB
testcase_19 AC 165 ms
5,888 KB
testcase_20 AC 132 ms
5,376 KB
testcase_21 AC 175 ms
6,144 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,r=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);
        auto _it=it;_it--;
        if(*it==cor)ans+=b;
        else if(it==arr.end())ans+=max(a,b-abs(cor-*_it));
        else if(it==arr.begin())ans+=max(a,b-abs(*it-cor));
        else ans+=max({a,b-abs(cor-*_it),b-abs(*it-cor)});
    }cout << ans;
}
0