#include #include #include #include using namespace std; const int maxn=505; int N,C,x[maxn],y[maxn],tx[maxn],ty[maxn],lx,ly; int a[maxn][maxn],s[maxn][maxn]; inline int sum(int xx,int yy,int len) { int ax=tx[xx-1],ay=ty[yy-1]; int ox=upper_bound(tx,tx+lx,ax+len-1)-1-tx+1,oy=upper_bound(ty,ty+ly,ay+len-1)-1-ty+1; assert(ox>=xx&&oy>=yy); return s[ox][oy]-s[ox][yy-1]-s[xx-1][oy]+s[xx-1][yy-1]; } inline bool ok(int len) { for(int i=1;i<=lx;i++) for(int j=1;j<=ly;j++) if(sum(i,j,len)>=C) return true; return false; } int main() { #ifdef local freopen("pro.in","r",stdin); #endif scanf("%d%d",&C,&N); for(int i=0;i>1; if(ok(M)) res=M,R=M-1; else L=M+1; } printf("%d\n",res); return 0; }