国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

506. Relative Ranks

2019-11-08 03:24:45
字體:
來源:轉載
供稿:網友

Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: “Gold Medal”, “Silver Medal” and “Bronze Medal”.

Example 1:

Input: [5, 4, 3, 2, 1]Output: ["Gold Medal", "Silver Medal", "Bronze Medal", "4", "5"]Explanation: The first three athletes got the top three highest scores, so they got "Gold Medal", "Silver Medal" and "Bronze Medal". For the left two athletes, you just need to output their relative ranks according to their scores.

Note: N is a positive integer and won’t exceed 10,000. All the scores of athletes are guaranteed to be unique.

class Solution {public: struct Player{ int score; int idx; bool Operator < (const Player& rhs) const{ return score < rhs.score; } }player[10005]; vector<string> findRelativeRanks(vector<int>& nums) { int size = nums.size(); for(int i = 0; i < size; ++i){ player[i].score = nums[i]; player[i].idx = i; } sort(player, player + size); vector<string> ans(size); for(int i = 0; i < size; ++i){ if(i == size - 3) ans[player[i].idx] = "Bronze Medal"; else if(i == size - 2) ans[player[i].idx] = "Silver Medal"; else if(i == size - 1) ans[player[i].idx] = "Gold Medal"; else { char s[8]; s
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 巴里| 忻州市| 沙河市| 萨迦县| 贺兰县| 米林县| 洪洞县| 桓仁| 东乡县| 青田县| 东乡县| 温泉县| 柞水县| 海伦市| 元谋县| 淳安县| 镇安县| 桂阳县| 土默特左旗| 文安县| 洛宁县| 松溪县| 海盐县| 乌兰察布市| 丰都县| 会东县| 玉溪市| 定日县| 伊金霍洛旗| 松滋市| 邢台市| 建始县| 大石桥市| 徐汇区| 广东省| 新兴县| 格尔木市| 邢台市| 海晏县| 苏尼特左旗| 和顺县|