#include #include #include #include #include #include #include // istringstream #include // sort #include // pair #include // DBL_MAX typedef long long ll; using namespace std; struct log { int pos; int cost; int time; }; int main(){ ll N,C,V; // [50],[300],[1500] cin >> N >> C >> V; vector ss(V), ts(V), cs(V), ms(V); for(int i=0; i> ss[i]; } for(int i=0; i> ts[i]; } for(int i=0; i> cs[i]; } for(int i=0; i> ms[i]; } auto gt = [](struct log l, struct log r)->bool { return l.time > r.time; }; // increacing order of time priority_queue, decltype(gt)> roots(gt); struct log start = {1,0,0}; roots.push(start); while(true){ if(roots.empty()) { break; } struct log crr = roots.top(); roots.pop(); //cout< C) { continue; } struct log next = {ts[i], crr.cost+cs[i], crr.time+ms[i]}; roots.push(next); } } cout << -1 << endl; //// TLE, search all root whose cost roots; // struct log tmp = {1,0,0}; // roots.push(tmp); // int minTime = maxN*maxM; // while(true){ // if(roots.empty()){ break; } // struct log crr = roots.front(); // for(int i=0; i