We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<stdio.h>#include<string.h>#include<math.h>#include<stdlib.h>structpoints{longintx,y;};longintmax(longinta,longintb){longintres;if(a<0)a=-a;if(b<0)b=-b;res=a>=b?a:b;returnres;}intmain(){/* Enter your code here. Read input from STDIN. Print output to STDOUT */intn,q;scanf("%d %d",&n,&q);structpoints*Kings=(structpoints*)malloc(n*sizeof(structpoints));for(inti=0;i<n;i++){scanf("%ld %ld",&(Kings[i]->x),&(Kings[i]->y));}longintqx,qy;for(inti=0;i<q;i++){scanf("%ld %ld",&qx,&qy);longintres=0;for(intj=0;j<n;j++){//min(Kings[j]->x,Kings[j]->y,qx,qy)res+=max((Kings[j]->x)-x,(Kings[j]->y)-y);}printf("%ld",res);}return0;}
Moving the Kings
You are viewing a single comment's thread. Return to all comments →
Problem's in here
and here
please help me out