-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathProgram.cs
40 lines (31 loc) · 1.38 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Linq;
namespace Climbing_the_Leaderboard {
class Program {
static int[] ClimbingLeaderboard(int[] scores, int[] alice) {
int[] ranking = scores.Distinct().ToArray();
int totalRankingPositions = ranking.Length;
int[] aliceRanking = new int[alice.Length];
for (int i = 0; i < alice.Length; i++) {
while (totalRankingPositions > 0) {
if (alice[i] >= ranking[totalRankingPositions - 1]) {
totalRankingPositions -= 1;
} else {
aliceRanking[i] = totalRankingPositions + 1;
break;
}
}
if (totalRankingPositions == 0) aliceRanking[i] = 1;
}
return aliceRanking;
}
static void Main(string[] args) {
int scoresCount = Convert.ToInt32(Console.ReadLine());
int[] scores = Array.ConvertAll(Console.ReadLine().Split(' '), scoresTemp => Convert.ToInt32(scoresTemp));
int aliceCount = Convert.ToInt32(Console.ReadLine());
int[] alice = Array.ConvertAll(Console.ReadLine().Split(' '), aliceTemp => Convert.ToInt32(aliceTemp));
int[] result = ClimbingLeaderboard(scores, alice);
Console.WriteLine(string.Join("\n", result));
}
}
}