public class Solution {
    public string[] FindRelativeRanks(int[] score) {
        var pq = new PriorityQueue<int, int>(
            score.Select((s, i) => (i, s)),
            Comparer<int>.Create((a, b) => b.CompareTo(a)));
 
        string[] medals = { "Gold Medal", "Silver Medal", "Bronze Medal" };
        var answer = new string[score.Length];
 
        for (int rank = 0; rank < score.Length; rank++) {
            int index = pq.Dequeue();
            answer[index] = rank < 3 ? medals[rank] : (rank + 1).ToString();
        }
 
        return answer;
    }
}

We create a pq, which is max heap since we pass that comparer, and we pass score array in it, such that scores are taken as priority of pq and index is taken as values of pq.

Now, we do a for loop, and we dequeue from pq. It comes out of course as rank 1, rank 2 and so on. So we assign it to the correct index in the answer array.