Bzoj1218 [hnoi2003] laser bomb

Source: Internet
Author: User

After the question is written, it should be DP ..

It was originally a scanning line + line segment tree, but it was still possible to squeeze 5000 ^ 2, so the brute force enumeration square + so-called DP was solved.

 1 #include <cstdio> 2 #include <cmath> 3 #include <algorithm> 4  5 using namespace std; 6  7 int a[5005][5005]; 8  9 int main(){10     int n, R, x, y, c, i, j, ans = 0, maxc = 5002;11     scanf("%d%d", &n ,&R);12     while (n--){13         scanf("%d%d%d", &x, &y, &c);14         a[x + 1][y + 1] = c;15     }16     for (int i = 1; i < maxc; ++i)17         for (int j = 1; j < maxc; ++j)18             a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];19     maxc -= R;20     for (int i = 0; i < maxc; ++i)21         for (int j = 0; j < maxc; ++j)22             ans = max(ans, a[i + R][j + R] + a[i][j] - a[i + R][j] - a[i][j + R]);23     printf("%d\n", ans);        24     return 0;    25 }
View code

 

Bzoj1218 [hnoi2003] laser bomb

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.