제출 #994604

#제출 시각아이디문제언어결과실행 시간메모리
994604emptypringlescanJobs (BOI24_jobs)C++17
29 / 100
90 ms22456 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int n; long long mon; vector<pair<int,long long> > adj[300005]; long long off; priority_queue<pair<long long,int> > pq; int32_t main(){ ios::sync_with_stdio(0); cin.tie(0); cin >> n >> mon; long long org=mon; for(int i=1; i<=n; i++){ long long a,b; cin >> a >> b; adj[b].push_back({i,a}); } pq.push({mon,0}); while(!pq.empty()){ pair<long long,int> x=pq.top(); pq.pop(); x.first+=off; if(x.first<0) continue; if(x.first>mon){ off+=x.first-mon; mon=x.first; } for(auto i:adj[x.second]){ pq.push({x.first+i.second-off,i.first}); } } cout << mon-org; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...