-
Notifications
You must be signed in to change notification settings - Fork 0
/
P1.c
77 lines (62 loc) · 1.2 KB
/
P1.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
69
70
71
72
73
74
75
76
77
#include <stdio.h>
#include <stdlib.h>
int mai(int *v, int n)
{
if (n == 1)
{
return *v;
}
else
{
int elem = mai(v, n - 1);
if (v[n - 1] > elem)
{
return v[n - 1];
}
else
{
return elem;
}
}
}
int main()
{
int d, a, s, m, code, mat, ap, maior;
scanf("%d", &d);
while (scanf("%d %d %d", &a, &s, &m) != EOF)
{
int *disp = (int *)calloc(d, sizeof(int));
maior = 0;
while (m)
{
scanf("%d %d %d", &code, &mat, &ap);
for (int i = 0; i < d; i++)
{
if (i == code)
{
disp[i] += (mat - ap);
}
}
m--;
}
for (int i = 0; i < d; i++)
{
if (disp[i] > maior)
{
maior = disp[i];
}
}
printf("%d/%d\n", s, a);
for (int i = 0; i < d; i++)
{
if (maior == disp[i])
{
printf("%d ", i);
}
disp[i] = 0;
}
printf("\n\n");
free(disp);
}
return 0;
}