C++ | easy to understand
\tclass Solution {\n\tpublic:\n\t\tstruct comp{\n\t\t\tbool operator()(const pair& a, const pair& b){\n\t\t\t\treturn a.second > b.second;\n\t\t\t}\n\t\t};\n\t\
\tclass Solution {\n\tpublic:\n\t\tstruct comp{\n\t\t\tbool operator()(const pair<int,int>& a, const pair<int,int>& b){\n\t\t\t\treturn a.second > b.second;\n\t\t\t}\n\t\t};\n\t\tvector<int> busiestServers(int k, vector<int>& arrival, vector<int>& load) {\n\t\t\tpriority_queue< pair<int,int> ,vector<pair<int,int>>,comp> qu; // for busy server\n\t\t\tset<int> S; // for non-busy server\n\t\t\tfor(int i = 0;i < k; i++ ){\n\t\t\t\tS.insert(i);\n\t\t\t}\n\t\t\tvector<int> ans;\n\t\t\tvector<int> server(k,0);\n\n\t\t\tfor(int i = 0;i < arrival.size(); i++){\n\t\t\t\tint ii = i % k;\n\t\t\t\twhile(!qu.empty() && qu.top().second <= arrival[i]){\n\t\t\t\t\tS.insert(qu.top().first);\n\t\t\t\t\tqu.pop();\n\t\t\t\t}\n\t\t\t\tif(S.empty()) continue;\n\t\t\t\tauto it = S.lower_bound(ii);\n\t\t\t\tif( it == S.end() ){\n\t\t\t\t\tqu.push( make_pair( *S.begin(), arrival[i] + load[i] ) );\n\t\t\t\t\tserver[*S.begin()]++;\n\t\t\t\t\tS.erase(S.begin());\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tqu.push( make_pair( *it, arrival[i] + load[i] ) );\n\t\t\t\t\tserver[*it]++;\n\t\t\t\t\tS.erase(*it);\n\t\t\t\t}\n\t\t\t}\n\t\t\tint big = 0;\n\t\t\tfor(int i = 0;i < k; i++){\n\t\t\t\tbig = max(big,server[i]);\n\t\t\t}\n\t\t\tfor(int i = 0 ;i < k; i++){\n\t\t\t\tif(server[i] == big)\n\t\t\t\t\tans.push_back( i );\n\t\t\t}\n\t\t\treturn ans;\n\t\t}\n\t};
[]