9 #define MAX 1200 // cheat, by using wc on input file
10 typedef struct entry entry
;
18 compare (const void *a
, const void *b
)
20 const entry
*e1
= a
, *e2
= b
;
21 return e1
->lo
< e2
->lo
? -1 : e1
->lo
> e2
->lo
;
25 main (int argc
, char **argv
)
29 while (scanf ("%d-%d\n", &lo
, &hi
) == 2) {
34 qsort (list
, count
, sizeof *list
, compare
);
35 printf ("read and sorted %d entries\n", count
);
37 unsigned int total
= 0;
38 for (int i
= 0; i
< count
; i
++) {
39 if (min
< list
[i
].lo
) {
40 total
+= list
[i
].lo
- min
;
43 if (list
[i
].lo
<= min
&& list
[i
].hi
>= min
) {
49 if (list
[count
- 1].hi
< -1U)
51 printf ("total %u\n", total
);