이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (1000005)
int main() {
ios_base::sync_with_stdio(false);cin.tie(0);
ll N,D;
cin>>N>>D;
N++;
pair<ll,pair<ll,ll> > arr[N];
for(ll i = 0;i < N - 1;i++){
cin>>arr[i].first>>arr[i].second.first>>arr[i].second.second;
}
arr[N - 1].first = D, arr[N - 1].second.first = 0, arr[N - 1].second.second = 0;
ll F = 0;
ll cur = 0; //F + all A[i]
sort(arr,arr + N);
priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > > pq;
for(ll i = 0;i < N;i++){
if(cur < arr[i].first){
F += arr[i].first - cur;
cur = arr[i].first;
}
while(!pq.empty() && pq.top().first < F){
cur -= pq.top().second;
pq.pop();
if(cur < arr[i].first){
F += arr[i].first - cur;
cur = arr[i].first;
}
}
if(F <= arr[i].second.second){
cur += arr[i].second.first;
pq.push(make_pair(arr[i].second.second,arr[i].second.first));
}
}
cout<<F<<'\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |