n,w,h = map(int,input().split())
monsters = []
ma = 0
for _ in range(n):
x,y,v = map(int,input().split())
monsters.append((x,y,v))
ma = max(ma,max(x,y))
def max_score(ma,w,h,monsters):
pres = [[0]*ma for _ in range(ma)]
for x,y,v in monsters:
pres[x][y]=v
for i in range(1,ma):
for j in range(1,ma):
pres[i][j] += pres[i-1][j] + pres[i][j-1] - pres[i-1][j-1]
ans = 0
for i in range(w,ma):
for j in range(h,ma):
score = pres[i][j]-pres[i-w][j]-pres[i][j-h]+pres[i-w][j-h]
ans = max(ans,score)
return ans
print(max_score(ma+2,w,h,monsters))
消灭怪物得最高分(二维前缀和)
最新推荐文章于 2024-07-30 17:23:09 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)