国产探花免费观看_亚洲丰满少妇自慰呻吟_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
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 龙州县| 来安县| 礼泉县| 历史| 逊克县| 卓资县| 富裕县| 开远市| 南雄市| 广东省| 崇仁县| 渝北区| 游戏| 肥西县| 襄城县| 曲阜市| 稻城县| 雅安市| 莒南县| 嘉定区| 基隆市| 齐齐哈尔市| 仲巴县| 岳阳县| 五寨县| 新宁县| 西盟| 平顶山市| 沐川县| 房产| 武夷山市| 富平县| 钦州市| 来宾市| 漳州市| 高台县| 新密市| 囊谦县| 兴化市| 普宁市| 苗栗市|