Untitled
unknown
plain_text
a year ago
1.4 kB
4
Indexable
#include <iostream> #include <queue> #include <vector> #include <utility> using namespace std; long long V; int get_there( vector<pair<int ,int> &arr, int start, int des, int fuel ) { cnt += 1 if ( des <= fuel - start ) return cnt; if ( des > fuel && arr[0].first + fuel } int main() { int n, q; long long T, Vi; T = V; cin >> n >> q >> V; vector<pair<int, int>> gas_station(n); vector<int> location(q); priority_queue<pair<int, int> , vector<pair<int, int>>, greater<pair<int ,int>>> pq; for ( int i = 0; i < n; i++ ) { int x, v; cin >> x >> v; T += v; pq.push( make_pair( x, v ) ); } for ( int i = 0; i < n; i++ ) { gas_station[i] = pq.top(); pq.pop(); } for ( auto &x : location ) cin >> x; for ( int i = 0; i < q; i++ ) { Vi = V; if ( location[i] > T ) cout << -1 << "\n"; else { if ( location[i] <= V ) cout << 0 << "\n"; else { cnt = 0; if ( get_there( gas_station, 0, location[i], cnt, Vi ) ) cout << cnt << "\n"; else cout << -1 << "\n"; } } } return 0; }
Editor is loading...
Leave a Comment