結果

問題 No.2408 Lakes and Fish
ユーザー Ngô Lê HoàngNgô Lê Hoàng
提出日時 2023-12-31 12:13:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 756 bytes
コンパイル時間 1,816 ms
コンパイル使用メモリ 168,804 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-31 12:13:36
合計ジャッジ時間 5,118 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 49 ms
6,676 KB
testcase_05 AC 49 ms
6,676 KB
testcase_06 AC 48 ms
6,676 KB
testcase_07 AC 61 ms
6,676 KB
testcase_08 AC 64 ms
6,676 KB
testcase_09 AC 61 ms
6,676 KB
testcase_10 AC 60 ms
6,676 KB
testcase_11 AC 32 ms
6,676 KB
testcase_12 AC 45 ms
6,676 KB
testcase_13 AC 13 ms
6,676 KB
testcase_14 AC 25 ms
6,676 KB
testcase_15 AC 48 ms
6,676 KB
testcase_16 AC 18 ms
6,676 KB
testcase_17 AC 15 ms
6,676 KB
testcase_18 AC 29 ms
6,676 KB
testcase_19 AC 47 ms
6,676 KB
testcase_20 AC 44 ms
6,676 KB
testcase_21 AC 49 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define each(a,x) for (auto& x: a)
const char nl = '\n';
void solve(){
    int n,m; cin >> n >> m;
    vector<int> l(n);
    each(l,x) cin >> x;
    ll ans = 0;
    for (int i = 0; i < m; i++){
        int f,b,w; cin >> f >> b >> w;
        int cur = INT_MAX;
        auto it = lower_bound(all(l),f);
        if (it != l.end()) cur = min(cur, *it - f);
        if (it != l.begin()) cur = min(cur, f - *(--it));
        ans += max(b, w - cur);
    }
    cout << ans << nl;


}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t = 1; //cin >> t;
    while (t--){
        solve();
    }
}
0