結果

問題 No.2408 Lakes and Fish
ユーザー IceKnight1093IceKnight1093
提出日時 2023-08-11 21:27:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 775 bytes
コンパイル時間 2,258 ms
コンパイル使用メモリ 202,648 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 12:16:25
合計ジャッジ時間 4,092 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 49 ms
5,376 KB
testcase_05 AC 48 ms
5,376 KB
testcase_06 AC 48 ms
5,376 KB
testcase_07 AC 60 ms
5,376 KB
testcase_08 AC 60 ms
5,376 KB
testcase_09 AC 60 ms
5,376 KB
testcase_10 AC 61 ms
5,376 KB
testcase_11 AC 32 ms
5,376 KB
testcase_12 AC 43 ms
5,376 KB
testcase_13 AC 13 ms
5,376 KB
testcase_14 AC 26 ms
5,376 KB
testcase_15 AC 48 ms
5,376 KB
testcase_16 AC 18 ms
5,376 KB
testcase_17 AC 15 ms
5,376 KB
testcase_18 AC 29 ms
5,376 KB
testcase_19 AC 46 ms
5,376 KB
testcase_20 AC 44 ms
5,376 KB
testcase_21 AC 48 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include "bits/stdc++.h"
using namespace std;
using ll = long long int;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);

    int n, m; cin >> n >> m;
    vector<int> pos(n);
    for (int &x : pos) cin >> x;
    ll ans = 0;
    for (int i = 0; i < m; ++i) {
        int y, a, b; cin >> y >> a >> b;
        auto it = lower_bound(begin(pos), end(pos), y);
        int add = a;
        if (it != end(pos)) add = max(add, b - (*it - y));
        if (it != begin(pos)) {
            --it;
            add = max(add, b - (y - *it));
        }
        ans +=add;
    }
    cout << ans << '\n';
}
0