5 struct tariff { int kmax, price; };
7 struct tariff tar[] = {
45 for(t=0; tar[t].kmax < km; t++)
52 return t ? tar[t-1].kmax+1 : 0;
55 #define hi(t) tar[t].kmax
56 #define pri(t) tar[t].price
58 int main(int argc, char **argv)
64 fprintf(stderr, "Usage: %s <km>\n", argv[0]);
71 printf("Original: %d-%d %d\n", lo(t), hi(t), pri(t));
79 // printf("Trying %d-%d %d-%d\n", lo(t), hi(t), l0, h0);
82 int p = pri(t) + pri(l);
83 int L = lo(l) < l0 ? l0 : lo(l);
84 int H = hi(l) > h0 ? h0 : hi(l);
85 // printf("Combined %d-%d %d-%d: p=%d\n", lo(l), hi(l), L, H, p);
87 printf("::: %d-%d(%d) + %d-%d(%d) = %d (saved %d)\n",