/home/toolbox/public_html/solutions/118/11850/a.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <fcntl.h>
6 #include <stdint.h>
7 #include <math.h>
8 #include <stdlib.h>
9 #include <ctype.h>
10
11 #define TRUE (1 == 1)
12 #define FALSE (1 != 1)
13
14 #define DEBUG if (FALSE)
15
16 /*
17 * Author: Isaac Traxler
18 * Date: 2021-12-6
19 * Purpose: fun
20 * Problem: 11850 - Alaska
21 */
22
23 /**********************************************
24 * ********************************************
25 * Problem statement bug
26 * Problem says start is 1422
27 * It is actually 1520
28 * ********************************************
29 *********************************************
30 */
31
32 /*
33 * This template reads data until a terminating value is reached.
34 */
35
36 #define MAX_STOPS 1520
37 #define MAX 200
38 #define START 1520
39
40 int cnt;
41 int stops[MAX_STOPS];
42
43 void init()
44 {
45 /* FUNCTION init */
46 } /* FUNCTION init */
47
48 void dump()
49 {
50 /* FUNCTION dump */
51 } /* FUNCTION dump */
52
53 int compare(const void *a, const void *b)
54 {
55 /* FUNCTION compare */
56 return ( *(int*)b - *(int*)a );
57 } /* FUNCTION compare */
58
59 int getInput()
60 {
61 /* FUNCTION getInput */
62 int dataReadFlag;
63 int i;
64
65 scanf(" %d ", &cnt);
66 dataReadFlag = (0 != cnt);
67 if (dataReadFlag)
68 {
69 /* load stops */
70 for (i=0; cnt>i; i++)
71 {
72 /* read a stop */
73 scanf(" %d ", &stops[i]);
74 } /* read a stop */
75 } /* load stops */
76 qsort(stops, cnt, sizeof(int), compare);
77 return (dataReadFlag);
78 } /* FUNCTION getInput */
79
80 void process()
81 {
82 /* FUNCTION process */
83 int i;
84 int dist;
85 int next;
86 int madeIt = TRUE;
87
88 dist = START;
89 i = 0;
90 DEBUG printf("cnt %d %d\n", cnt, stops[0]);
91 while ((cnt>i) && (MAX >= (dist - stops[i])))
92 {
93 /* while */
94 DEBUG printf("(cnt %d) (max %d) > (%d = %d - stops[%d]%d)\n", cnt, MAX, (dist-stops[i]), dist, i, stops[i]);
95 if (MAX >= (dist - stops[i]))
96 {
97 /* made it to next stop */
98 dist = stops[i];
99 } /* made it to next stop */
100 i++;
101 } /* while */
102 if (MAX >= dist)
103 {
104 printf("POSSIBLE\n");
105 }
106 else
107 {
108 printf("IMPOSSIBLE\n");
109 }
110 } /* FUNCTION process */
111
112 int main()
113 {
114 /* main */
115 int moreToDo;
116
117 init();
118 moreToDo = getInput();
119 while (moreToDo)
120 {
121 /* while */
122 process();
123 moreToDo = getInput();
124 } /* while */
125
126 return EXIT_SUCCESS;
127 } /* main */
128