Lang:GCC
Edit12345678910111213141516171819202122232425262728293031#include <stdio.h>#include <stdlib.h>#define MAX_NODE (10000)typedef struct _node_t{struct _node_t *fc, *ns; //first child, next siblingint p, q;int mbm, sell; //minimun beginning moneyint id;}tree_node_t, *tree_t;static tree_node_t** tmp_arr;static tree_node_t nodes[MAX_NODE+1]; //nodes[0] is skippedstatic int depth;int cmp(const void* p1, const void* p2) {tree_node_t *n1 = *((tree_node_t**) p1);tree_node_t *n2 = *((tree_node_t**) p2);if(n1->sell < n2->sell) {return 1;} else if(n1->sell == n2->sell) {return 0;} else {return -1;}}