Moved kattis from Uni repo
This commit is contained in:
25
kattis/problems/01_11_23/refrigerator/main.c
Normal file
25
kattis/problems/01_11_23/refrigerator/main.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int pa, ka, pb, kb, n;
|
||||
scanf("%d %d %d %d %d", &pa, &ka, &pb, &kb, &n);
|
||||
|
||||
int tripsA = 0, tripsB = 0;
|
||||
int totalCost = 0;
|
||||
int costA = pa/ka;
|
||||
int costB = pb/kb;
|
||||
|
||||
while (n > 0) {
|
||||
if (costA < costB && ka < n) {
|
||||
tripsA++;
|
||||
totalCost += pa;
|
||||
} else {
|
||||
tripsB++;
|
||||
totalCost += pb;
|
||||
}
|
||||
n--;
|
||||
}
|
||||
printf("%d %d %d\n", tripsA, tripsB, totalCost);
|
||||
return 0;
|
||||
}
|
26
kattis/problems/01_11_23/refrigerator/main.c.orig
Normal file
26
kattis/problems/01_11_23/refrigerator/main.c.orig
Normal file
@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int pa, ka, pb, kb, n;
|
||||
scanf("%d %d %d %d %d", &pa, &ka, &pb, &kb, &n);
|
||||
|
||||
int tripsA = 0, tripsB = 0;
|
||||
int totalCost = 0;
|
||||
int costA = pa/ka;
|
||||
int costB = pb/kb;
|
||||
|
||||
|
||||
while (n > 0) {
|
||||
if (pa < pb && ka < n) {
|
||||
tripsA++;
|
||||
totalCost += pa;
|
||||
} else {
|
||||
tripsB++;
|
||||
totalCost += pb;
|
||||
}
|
||||
n--;
|
||||
}
|
||||
printf("%d %d %d\n", tripsA, tripsB, pa+pb);
|
||||
return 0;
|
||||
}
|
BIN
kattis/problems/01_11_23/refrigerator/program
Executable file
BIN
kattis/problems/01_11_23/refrigerator/program
Executable file
Binary file not shown.
Reference in New Issue
Block a user