-
Notifications
You must be signed in to change notification settings - Fork 0
/
Problema-E.c
37 lines (34 loc) · 888 Bytes
/
Problema-E.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
//Problema E - Prefeito Tecnológico em C
#include <stdio.h>
typedef struct {
int custo;
int votos;
} Melhoria;
int main() {
int N;
scanf("%d", &N);
while (N--) {
int T, L;
scanf("%d %d", &T, &L);
Melhoria melhorias[L];
for (int i = 0; i < L; i++) {
scanf("%d %d", &melhorias[i].custo, &melhorias[i].votos);
}
int maxVotos = 0;
int custoTotal = 0;
for (int i = 0; i < L; i++) {
if (melhorias[i].custo <= T) {
if (melhorias[i].votos > maxVotos) {
maxVotos = melhorias[i].votos;
custoTotal = melhorias[i].custo;
}
}
}
if (maxVotos == 0) {
printf("NO FUNDS\n");
} else {
printf("%d %d\n", maxVotos, T - custoTotal);
}
}
return 0;
}