Skip to content

Instantly share code, notes, and snippets.

@magicleon94
Created September 30, 2017 17:12
Show Gist options
  • Save magicleon94/67e80f926e84b1ed965292866a3f5af8 to your computer and use it in GitHub Desktop.
Save magicleon94/67e80f926e84b1ed965292866a3f5af8 to your computer and use it in GitHub Desktop.
#!/bin/python
import sys
if __name__ == "__main__":
n = int(raw_input().strip())
m = int(raw_input().strip())
grid = [[0 for k in range(n)] for i in range(n)]
for a0 in xrange(m):
x, y, w = raw_input().strip().split(' ')
x, y, w = [int(x), int(y), int(w)]
grid[x][y] += w
for d in range(1,w):
for kx in [-d,d]:
for ky in range(-d,d+1):
newX = x+kx
newY = y+ky
if newX>=0 and newX<n and newY>=0 and newY<n:
grid[newX][newY] += w-d
for ky in [-d,d]:
for kx in range(-d+1,d):
newX = x+kx
newY = y+ky
if newX>=0 and newX<n and newY>=0 and newY<n:
grid[newX][newY] += w-d
print max([max(x) for x in grid])
#for x in grid:
#print x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment