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.
map<int,int>mp={{0,0}};//d->exceedmap<int,int>::iteratormaxdif=mp.begin();//iterator to mp item with most exceedmap<int,int>::iteratorgetIterator(intd){if(d<=maxdif->first)returnmaxdif;autoiv=mp.insert({d,0});autoit=iv.first;if(iv.second){//new d;autoprevit=it;previt--;it->second=previt->second+previt->first-it->first;}returnit;}inttaskScheduling(intd,intm){map<int,int>::iteratorit=getIterator(d);while(it!=mp.end()){it->second+=m;if(it->second>maxdif->second){maxdif=it;}it++;}returnmaxdif->second;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Task Scheduling
You are viewing a single comment's thread. Return to all comments →
My C++ solution: