BZOJ1218[HNOI2003] Laser bombs

Source: Internet
Author: User

BZOJ1218[HNOI2003] Laser bombs

Test instructions

There are n targets in the coordinate system, each of which has a value, and now a square with an edge that is an R, which is the maximum value of the target in its interior (the original question does not include the boundary, but in fact it is not).

Exercises

Preprocess the two-dimensional prefix of the node with a horizontal ordinate, and then enumerate the coordinates of the upper right corner of the square. Note You can move the coordinate system up one unit to the right and leave the prefixes and negative numbers in mind. Reflection: Konjac konjac Good weak ah, the enumeration of I and J boundary should be the maximum value of the node horizontal axis maximum and ordinate maximum value. Konjac Konjac did not notice this at first, thinking that he was pre-written wrong. Change to change, WA to WA to go. Finally, a little change in the calibration process to find the problem. Qaq

Code:

1#include <cstdio>2#include <cstring>3#include <algorithm>4 #defineMAXN 55005 #defineInc (I,J,K) for (int i=j;i<=k;i++)6 using namespacestd;7 8 intsum[maxn][maxn],n,mxxy,r,mx;9 intMain () {Tenscanf"%d%d", &n,&r); mxxy=mx=0; OneInc (I,1, N) { A         intX, Y, Z scanf"%d%d%d", &x,&y,&z); x + +; y++; -Mxxy=max (MXXY,X); Mxxy=max (Mxxy,y); sum[x][y]+=Z; -     } theInc (I,1, Mxxy) Inc (J,1, Mxxy) -sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]; - Inc (I,R,MXXY) Inc (J,R,MXXY) -Mx=max (mx,sum[i][j]-sum[i][j-r]-sum[i-r][j]+sum[i-r][j-R]); +printf"%d", MX);return 0; -}

20160602

BZOJ1218[HNOI2003] Laser bombs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.