Site Message
Only Premium Users can view the Question
/* * Complete the 'socialGraphs' function below. * * The function accepts INTEGER_ARRAY counts as parameter. */ void socialGraphs(vectorcounts) { vector g[200020]; set tes; for (int i = 0; i < counts.size(); ++i) { g[counts[i]].push_back(i); tes.insert(counts[i]); } vector > op; for (auto xx: tes) { int i = 0; vector curs; for (auto yy: g[xx]) { curs.push_back(yy); //cout << yy << " "; ++i; if (i % xx == 0) { i = 0; //cout << "\n"; op.push_back(curs); curs.clear(); } } } sort(op.begin(), op.end()); for (int i = 0; i < op.size(); i++) { for (auto xx: op[i]) cout << xx << " "; cout << "\n"; } }
/* * Complete the 'minTime' function below. * * The function is expected to return an INTEGER. * The function accepts following parameters: * 1. INTEGER_ARRAY processorTime * 2. INTEGER_ARRAY taskTime */ int minTime(vectorptime, vector task) { assert(ptime.size()*4 == task.size()); sort(ptime.begin(), ptime.end()); sort(task.begin(), task.end()); reverse(task.begin(), task.end()); int ans = 0; for (int i = 0; i < (int)task.size(); i += 4) { int j = i / 4; ans = max(ans, task[i]+ptime[j]); } return ans; }