結果
| 問題 | No.3459 Defeat Slimes |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-02-28 16:33:49 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,724 bytes |
| 記録 | |
| コンパイル時間 | 4,371 ms |
| コンパイル使用メモリ | 351,368 KB |
| 実行使用メモリ | 14,284 KB |
| 最終ジャッジ日時 | 2026-02-28 16:34:02 |
| 合計ジャッジ時間 | 12,268 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 WA * 10 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool chmax(auto &a, auto b) { return a < b ? a = b, 1 : 0; }
bool chmin(auto &a, auto b) { return a > b ? a = b, 1 : 0; }
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll N, Y, Z; cin >> N >> Y >> Z;
vector<tuple<ll,ll,ll>> S(N); // (L, X, C)
for (int i = 0; i < N; ++i) cin >> get<2>(S[i]) >> get<0>(S[i]) >> get<1>(S[i]);
sort(S.begin(), S.end());
int s = 0;
ll ans = 0;
priority_queue<pair<ll,ll>> pq;
for (; s < N && get<0>(S[s]) <= Y; ++s) {
auto [l, x, c] = S[s];
pq.push({x, c});
}
while (!pq.empty()) {
// cout << s << ' ' << Y << ' ' << ans << '\n';
if (s == N) {
while (!pq.empty()) {
auto [x, c] = pq.top(); pq.pop();
ll beat = min((Z - Y + x - 1) / x /* ceil(Z-Y / x) */, c);
ans += beat;
Y += x * beat;
if (Y >= Z) {
cout << ans << '\n';
return 0;
}
}
cout << -1 << '\n';
return 0;
}
while (!pq.empty() && Y < get<0>(S[s])) {
auto [x, c] = pq.top(); pq.pop();
ll beat = min((get<0>(S[s]) - Y + x - 1) / x, c);
ans += beat;
Y += x * beat;
if (beat < c) pq.push({x, c - beat});
}
if (Y < get<0>(S[s])) {
cout << -1 << '\n';
return 0;
}
for (; s < N && get<0>(S[s]) <= Y; ++s) {
auto [l, x, c] = S[s];
pq.push({x, c});
}
}
if (Y >= Z) cout << ans << '\n';
else cout << -1 << '\n';
}