-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy path10360.cpp
39 lines (34 loc) · 1008 Bytes
/
10360.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
/*
brute force > iterative
difficulty: easy
date: 13/Jan/2020
by: @brpapa
*/
#include <iostream>
#include <cstring>
#define MAX 1025
using namespace std;
int killed[MAX][MAX]; // quantos ratos morreriam se a bomba estive na posicao
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T; cin >> T;
while (T--) {
int D, N; cin >> D >> N;
memset(killed, 0, sizeof(killed));
for (int n = 0; n < N; n++) {
int X, Y, P; cin >> X >> Y >> P;
for (int x = max(X-D, 0); x <= min(X+D, MAX-1); x++)
for (int y = max(Y-D, 0); y <= min(Y+D, MAX-1); y++)
killed[x][y] += P;
}
int maxKilled = -1, maxX, maxY;
for (int x = 0; x < MAX; x++)
for (int y = 0; y < MAX; y++)
if (killed[x][y] > maxKilled) {
maxKilled = killed[x][y];
maxX = x; maxY = y;
}
cout << maxX << " " << maxY << " " << maxKilled << endl;
}
return 0;
}