結果

問題 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,506 ms
コンパイル使用メモリ 261,656 KB
実行使用メモリ 6,232 KB
最終ジャッジ日時 2023-08-28 13:34:56
合計ジャッジ時間 9,732 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 148 ms
6,016 KB
testcase_05 AC 148 ms
6,156 KB
testcase_06 AC 142 ms
6,216 KB
testcase_07 AC 170 ms
6,132 KB
testcase_08 AC 164 ms
6,232 KB
testcase_09 AC 164 ms
6,008 KB
testcase_10 AC 163 ms
6,004 KB
testcase_11 RE -
testcase_12 AC 117 ms
5,652 KB
testcase_13 AC 33 ms
4,376 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 46 ms
4,376 KB
testcase_17 RE -
testcase_18 AC 78 ms
4,692 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