A prefix and a great violence.
1#include <cstdio>2#include <iostream>3#include <cstring>4#include <cstdlib>5#include <cmath>6#include <queue>7#include <algorithm>8#include <vector>9 #defineM 5009Ten #defineEPS 1e-10 One #defineMO 10000 A #definell Long Long - using namespacestd; - ll Read () the { - CharCh=GetChar (); -ll x=0, f=1; - for(;ch<'0'|| Ch>'9'; ch=GetChar ()) + if(ch=='-') -f=-1; + for(; ch>='0'&&ch<='9'; ch=GetChar ()) Ax=x*Ten+ch-'0'; at returnx*F; - } - intN,sum[m][m],r,x[m],y[m]; - intMain () - { -n=read (); inR=read (); - for(intI=1; i<=n;i++) to { +X[i]=read () +1; -Y[i]=read () +1; thesum[x[i]][y[i]]+=read (); * } $ for(intI=1; i<=5001; i++)Panax Notoginseng for(intj=1; j<=5001; j + +) -sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]; ther--; + intmx=0; A for(intI=1; i<=5001-r;i++) the for(intj=1; j<=5001-r;j++) +Mx=max (mx,sum[i+r][j+r]-sum[i-1][j+r]-sum[i+r][j-1]+sum[i-1][j-1]); -printf"%d\n", MX); $ return 0; $}
Bzoj 1218: [HNOI2003] Laser bomb