結果
| 問題 | No.3459 Defeat Slimes |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-02-28 14:18:02 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 178 ms / 3,000 ms |
| コード長 | 1,363 bytes |
| 記録 | |
| コンパイル時間 | 4,213 ms |
| コンパイル使用メモリ | 347,668 KB |
| 実行使用メモリ | 16,904 KB |
| 最終ジャッジ日時 | 2026-02-28 14:18:14 |
| 合計ジャッジ時間 | 12,323 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#include<atcoder/modint>
using namespace atcoder;
using mint=modint998244353;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll N,Y,Z;
cin>>N>>Y>>Z;
vector<array<ll,3>> P(N);
for(int i=0;i<N;i++){
cin>>P[i][0]>>P[i][1]>>P[i][2];
}
vector<array<ll,2>> EV(N+2);
for(int i=0;i<N;i++)EV[i]={P[i][1],i};
EV[N]={Z,-1};
EV[N+1]={ll(2e18),-1};
ll an=0;
sort(EV.begin(),EV.end());
ll cn=0;
priority_queue<array<ll,2>> Q;
while(cn<=N+1&&EV[cn][0]<=Y){
int id=EV[cn][1];
if(id!=-1){
Q.push({P[id][2],P[id][0]});
}
cn++;
}
while(Y<Z){
if(Q.size()==0){
cout<<-1<<"\n";
return 0;
}
auto [v,nm]=Q.top();
Q.pop();
ll dff=EV[cn][0]-Y;
ll tim=(dff+v-1)/v;
// cout<<Y<<" "<<an<<" "<<v<<" "<<nm<<" "<<dff<<" "<<tim<<endl;
if(dff>0&&tim>nm){
an+=nm;
Y+=v*nm;
continue;
}
else{
if(nm>tim)Q.push({v,nm-tim});
Y+=v*tim;
an+=tim;
int id=EV[cn][1];
if(id!=-1){
Q.push({P[id][2],P[id][0]});
}
cn++;
}
}
cout<<an<<"\n";
}