-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathh_v.cpp
68 lines (66 loc) · 1.14 KB
/
h_v.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int n, m;
cin >> n;
cin >> m;
int arr[n][n];
map <string, bool> seen;
for (int i = 0; i<m; i++) {
int x, y, w;
cin >> x >> y >> w;
int sx = x;
int sy = y;
int ex = x;
int ey = y;
seen.clear();
while (w > 0) {
if (sx < 0)
sx = 0;
if (ex > n-1)
ex = n-1;
if (sy < 0)
sy = 0;
if (ey > n-1)
ey = n-1;
int j = sx;
while ( j <= ex ) {
int k = sy;
while (k<=ey) {
map<string,bool>::iterator it;
string key = to_string(j);
key = key + to_string(k);
it = seen.find(key);
if (it == seen.end()) {
arr[j][k] += w;
seen[key] = true;
}
k ++;
}
j ++;
w -= 1;
sx -= 1;
sy -= 1;
ex += 1;
ey += 1;
}
}
}
int max = 0;
for (int i=0; i<n; i++) {
for (int j = 0; j <n; j++) {
if (arr[i][j] > max) {
max = arr[i][j];
}
}
}
cout << max << endl;
return 0;
}