This repository has been archived by the owner on May 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp102.c
68 lines (54 loc) · 1.4 KB
/
p102.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
/* @JUDGE_ID: 6380MH 102 C "Brutal Force.. Just 3!" */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#define IN "p102.in"
#define OUT "p102.out"
int main(int argc, char *argv[]) {
unsigned int b1, g1, c1, b2, g2, c2, b3, g3, c3;
int mov = -1;
unsigned int t;
char c[4] = "TI!";
#ifndef ONLINE_JUDGE
close (0); open(IN, O_RDONLY);
/* close (1); open(OUT, O_WRONLY | O_CREAT, 0600); */
#endif
while (scanf("%i %i %i %i %i %i %i %i %i", &b1, &g1, &c1, &b2, &g2, &c2, &b3, &g3, &c3) == 9) {
t = b2 + b3 + c1 + c3 + g1 + g2; /* BCG */
if (t < mov) {
mov = t;
strcpy(c, "BCG");
}
t = b2 + b3 + c1 + c2 + g1 + g3; /* BGC */
if (t < mov) {
mov = t;
strcpy(c, "BGC");
}
t = b1 + b3 + c2 + c3 + g1 + g2; /* CBG */
if (t < mov) {
mov = t;
strcpy(c, "CBG");
}
t = b1 + b2 + c2 + c3 + g1 + g3; /* CGB */
if (t < mov) {
mov = t;
strcpy(c, "CGB");
}
t = b1 + b3 + c1 + c2 + g2 + g3; /* GBC */
if (t < mov) {
mov = t;
strcpy(c, "GBC");
}
t = b1 + b2 + c1 + c3 + g2 + g3; /* GCB */
if (t < mov) {
mov = t;
strcpy(c, "GCB");
}
printf("%s %i\n", c, mov);
mov = -1;
}
return 0;
}