fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4. #include <vector>
  5. #include <map>
  6. #include <stack>
  7. #include <stdio.h>
  8. #include <math.h>
  9. typedef std::vector<int> vi;
  10. using namespace std;
  11. #define max(a, b) (a < b ? b : a)
  12. #define min(a, b) (a > b ? b : a)
  13.  
  14. int main() {
  15. int t;
  16. static int killed[1025][1025];
  17. cin >>t;
  18. while(t--){
  19. int d, n, x, y, sz, max=0;
  20. cin >>d>>n;
  21. fill_n(&killed[0][0], 1025*1025,0);
  22. while(n--){
  23. cin >> x >>y>>sz;
  24. for(int X=max(0, x-d);X<=min(x+d, 1024);X++)
  25. for(int Y=max(0, y-d);Y<=min(y+d, 1024);Y++)
  26. killed[X][Y]+=sz;
  27. }
  28. for(int X=0;X<1025;X++)
  29. for(int Y=0;Y<1025;Y++)
  30. if(killed[X][Y]>max){
  31. max=killed[X][Y];
  32. x=X;y=Y;
  33. }
  34. cout<<x<<" "<<y<<" "<<max<<endl;
  35.  
  36. }
  37. return 0;
  38. }
Success #stdin #stdout 0s 7404KB
stdin
1
1
2
4 4 10
6 6 20
stdout
5 5 30