結果

問題 No.2408 Lakes and Fish
ユーザー hiro71687khiro71687k
提出日時 2023-08-28 13:34:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 778 bytes
コンパイル時間 4,714 ms
コンパイル使用メモリ 263,572 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-09 08:52:07
合計ジャッジ時間 8,549 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 137 ms
6,940 KB
testcase_05 AC 137 ms
6,940 KB
testcase_06 AC 129 ms
6,944 KB
testcase_07 AC 152 ms
6,944 KB
testcase_08 AC 156 ms
6,944 KB
testcase_09 AC 153 ms
6,940 KB
testcase_10 AC 157 ms
6,940 KB
testcase_11 RE -
testcase_12 AC 110 ms
6,940 KB
testcase_13 AC 30 ms
6,940 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 44 ms
6,940 KB
testcase_17 RE -
testcase_18 AC 72 ms
6,944 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll mod=998244353;
ll inf=1009999999999999990;
int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll>l(n+1);
    l[0]=-inf;
    for (ll i = 0; i < n; i++)
    {
        cin >> l[i+1];
    }
    l.push_back(inf);
    vector<ll>f(n),b(m),w(m);
    for (ll i = 0; i < m; i++)
    {
        cin >> f[i] >> b[i] >> w[i];
    }
    ll ans=0;
    for (ll i = 0; i < m; i++)
    {
        ll v=lower_bound(l.begin(),l.end(),f[i])-l.begin();
        ll x=min(f[i]-l[v-1],l[v]-f[i]);
        if (b[i]+x<w[i])
        {
            ans+=w[i]-x;
        }else{
            ans+=b[i];
        }
    }
    cout << ans << endl;
}
0