レースの後、times には全員のタイム(秒)が入っています。表彰台に上がれるのは速い 3 人だけです。podium(times) を書きましょう。速い順に並べ替え、最初の 3 つだけを残します。3 人未満なら全員残します。
podium({58, 52, 61, 55})→[52, 55, 58]podium({70, 65})→[65, 70]vector<int> podium(vector<int> times)#include <algorithm>
#include <vector>
using namespace std;
vector<int> podium(vector<int> times) {
// ここにコードを書く:並べ替えて最初の 3 つを残す
return times;
}
実行すると例で試せます。よさそうなら提出しましょう。