class LongJumpCompetition { public: vector<int> recoverStandings(vector<int> jumpLengths) { vector<int> ans; int N = jumpLengths.size() / 3; vector<pair<vector<int>, int>> cur(N); for (int i = 0; i < N; ++i) { cur[i] = { {} , i}; }
for (int i = 0; i < 3; ++i) { for (int j = 0; j < N; ++j) { int length = jumpLengths[i * N + j]; cur[N - 1 - j].first.push_back(-1 * length); sort(cur[N - 1 - j].first.begin(), cur[N - 1 - j].first.end()); } sort(cur.begin(), cur.end()); }
for (int i = 0; i < N; ++i) { ans.push_back(cur[i].second); }
return ans; } }
|