We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
boolcmp(pair<int,int>a,pair<int,int>b){if(a.first==b.first)returna.second<b.second;returna.first<b.first;}vector<int>jimOrders(vector<vector<int>>orders){vector<pair<int,int>>vp;//first: serve time, second: *th-customerintn=orders.size();for(inti=0;i<n;i++){vp.push_back(make_pair(orders[i][0]+orders[i][1],i));}sort(vp.begin(),vp.end(),cmp);vector<int>ans;for(inti=0;i<n;i++){ans.push_back(vp[i].second+1);}returnans;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Jim and the Orders
You are viewing a single comment's thread. Return to all comments →
C++