#include //--------------------------------------------------------------------------- int revisaRed(int k,int *coorX,int *coorY,int left,int right,int buttom,int top) { int resp,i; resp = 0; for(i = 0; i < k; i++) { if( left <= coorX[i] && coorX[i] <= right && buttom <= coorY[i] && coorY[i] <= top ) { resp++; } } return resp; } //--------------------------------------------------------------------------- int revisaPez(int n,int m,int k,int *coorX,int *coorY,int index) { int i,max,temp; max = 0; for(i = 0; i < n; i++) { temp = revisaRed(k,coorX,coorY,coorX[index],coorX[index]+m,coorY[index]-i,coorY[index]+n-i); if( temp > max ) max = temp; } return max; } //--------------------------------------------------------------------------- int main(void) { FILE *input,*output; int i,*coorX,*coorY,max,temp,n,m,k; /// Abrimos el archivo de entrada. input = fopen("input.txt","r+t"); /// Leemos los datos. fscanf(input,"%d %d %d",&n,&m,&k); coorX = new int[k]; coorY = new int[k]; for(i = 0; i < k; i++) fscanf(input,"%d %d",&coorX[i],&coorY[i]); /// Cerramos el archivo de entrada. fclose(input); max = 0; for(i = 0; i < k; i++) { temp = revisaPez(n,m,k,coorX,coorY,i); if(temp > max) max = temp; } /// Abrimos el archivo de salida. output = fopen("output.txt","w+t"); fprintf(output,"%d",max); /// Cerramos el archivo de salida y liberamos memoria. fclose(output); delete[] coorX; delete[] coorY; return 0; } //---------------------------------------------------------------------------