50149. Admission
難度:2.5/51
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#include <stdio.h>
#include <stdlib.h>
typedef struct{
int id;
int ch, en, ma, sc, ss;
int total;
} student;
int m, n;
student arr[20005] = {0};
int cmp(const void* aa, const void* bb){
student* a = (student*)aa;
student* b = (student*)bb;
if(a->total != b->total) return b->total - a->total;
if(a->ma != b->ma) return b->ma - a->ma;
if(a->en != b->en) return b->en - a->en;
if(a->sc != b->sc) return b->sc - a->sc;
if(a->ch != b->ch) return b->ch - a->ch;
return b->ss - a->ss;
}
void get_info(student* s){
scanf("%d %d %d %d %d %d", &s->id, &s->ch, &s->en, &s->ma, &s->sc, &s->ss);
s->total = s->ch + s->en + s->ma + s->sc + s->ss;
}
int all_same(student* a, student* b){
return (a->ch == b->ch) && (a->en == b->en) &&
(a->ma == b->ma) && (a->sc == b->sc) &&
(a->ss == b->ss);
}
int main(){
scanf("%d %d", &m, &n);
for(int i = 0; i < n; i++){
student* s = &arr[i];
get_info(s);
}
qsort(arr, n, sizeof(student), cmp);
int qualify = m;
student* last = &arr[m - 1];
for(int i = m; i < n; i++){
if(all_same(last, &arr[i])) qualify++;
else break;
}
for(int i = 0; i < qualify; i++){
printf("%d\n", arr[i].id);
}
}