-
Notifications
You must be signed in to change notification settings - Fork 0
/
Climbing the Leaderboard.c
63 lines (61 loc) · 1.29 KB
/
Climbing the Leaderboard.c
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
int main()
{
int n,rank=0;
scanf("%d",&n);
int scores[n];
for(int scores_i = 0; scores_i < n; scores_i++)
{
scanf("%d ",&scores[scores_i]);
if(scores!=0)
{
if (scores[scores_i]!=scores[scores_i-1] )
{
rank++;
}
}
else
rank++;
}
int a=0,original_scores[rank];
for(int i=0;i<n;i++)
{
if(scores[i]!=scores[i+1])
original_scores[a++]=scores[i];
}
int m;
scanf("%d",&m);
int alice[m];
for(int alice_i = 0; alice_i < m; alice_i++)
{
scanf("%d ",&alice[alice_i]);
}
int temp2=rank-1;
for(int i=0;i<m;i++)
{
for(int j=temp2;j>=0;j--)
{
if(alice[i]<original_scores[j])
{
printf("%d\n",j+2);
temp2=j;
break;
}
if(alice[i]==original_scores[j])
{
printf("%d\n",j+1);
temp2=j;
break;
}
if(j==0)
printf("%d\n",j+1);
}
}
return 0;
}