#include #include #include #define MAX 450 struct tah { int a,b; }; int a,b,n; tah at[MAX],bt[MAX],ot[MAX]; int at_len,bt_len,ot_len; int ot_cmp(const void *e1,const void *e2) { int dif=((tah *)e1)->a + ((tah *)e1)->b -((tah *)e2)->a - ((tah *)e2)->b; if (dif) return -dif; return ((tah *)e2)->a - ((tah *)e1)->a; } void rest_of_game(int a,int b,tah *bt,int bt_len,tah *ot, int ot_len,int *ao,int *bo) { for (int i=0;ia=ia; that->b=ib; } qsort(ot,ot_len,sizeof(tah),ot_cmp); //Alice bere vse sve... for (int i=0;i bestval) { bestval=bt[i].a+bt[i].b; best=i; } } as+=bt[best].a; bt[best].a=0; bt[best].b=0; rest_of_game(as,bs,bt,bt_len,ot,ot_len,&a2,&b2); // printf("(%d,%d)-(%d,%d) ",a1,b1,a2,b2); if ( (a2-b2 > a1-b1) || ( (a2-b2 == a1-b1) && a2>a1) ) { a1=a2; b1=b2; } } printf("%d %d\n",a1,b1); } return 0; }