結果

問題 No.3459 Defeat Slimes
コンテスト
ユーザー shingo0909
提出日時 2026-02-28 15:42:35
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,191 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,059 ms
コンパイル使用メモリ 350,724 KB
実行使用メモリ 17,484 KB
最終ジャッジ日時 2026-02-28 15:42:54
合計ジャッジ時間 17,812 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

struct s {
    ll c, l, x;
};

int main() {
    ll n, y, z;
    cin >> n >> y >> z;
    vector<s> v(n);
    for (auto &[c, l, x] : v)
        cin >> c >> l >> x;
    v.push_back({0LL, 1LL << 61, 0LL});
    sort(v.begin(), v.end(), [&](s a, s b) {
        return a.l < b.l;
    });
    priority_queue<pair<ll, ll>> q;
    int ind = 0;
    ll ans = 0;
    while (v[ind].l <= y) {
        q.push({v[ind].x, v[ind].c});
        ind++;
    }

    while (v[ind].l <= y || !q.empty()) {
        while (v[ind].l <= y) {
            q.push({v[ind].x, v[ind].c});
            ind++;
        }
        if ((z <= v[ind].l) && y + __int128(q.top().first) * q.top().second >= z) {
            cout << ans + (z - y - 1) / (q.top().first) + 1 << endl;
            return 0;
        }
        auto p = q.top();
        q.pop();
        ll r = (v[ind].l - y - 1) / (p.first) + 1;
        ans += min(r, p.second);
        y += min(r, p.second) * p.first;
        p.second -= min(r, p.second);
        if (p.second != 0)
            q.push(p);
    }
    cout << -1 << endl;
    return 0;
}
0