-
Notifications
You must be signed in to change notification settings - Fork 48
/
1125.c
68 lines (48 loc) · 1.03 KB
/
1125.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
64
65
66
67
68
/*
@autor: Malbolge;
@data: 19/02/2019;
@nome: Fórmula 1;
*/
#include <stdio.h>
#include <string.h>
#define true 1
#define false 0
#define MAXSIZE 105
#define INF 0x3f3f
typedef unsigned short us;
void main ()
{
us g, p, i, j, k;
us grid[MAXSIZE][MAXSIZE], pointS[MAXSIZE], pontos[MAXSIZE];
while (scanf("%hu %hu", &g, &p), g)
{
for (i = 0; i < g; ++i)
for (j = 0; j < p; ++j)
scanf("%hu", &grid[i][j]);
us _system;
scanf("%hu", &_system);
while (_system--)
{
memset(pontos, 0, sizeof(pontos));
memset(pointS, 0, sizeof(pointS));
scanf("%hu", &k);
for (i = 0; i < k; ++i)
scanf("%hu", &pointS[i]);
for (i = 0; i < g; ++i)
for (j = 0; j < p; ++j)
pontos[j] += pointS[grid[i][j] - 1];
us maior = 0;
for (i = 0; i < p; ++i)
if (pontos[i] > maior)
maior = pontos[i];
_Bool flag = true;
for (i = 0; i < p; ++i)
if (pontos[i] == maior)
if (flag)
printf("%hu", i + 1), flag = false;
else
printf(" %hu", i + 1);
printf("\n");
}
}
}