Advertisement
Saleh127

UVA 10360

Feb 11th, 2021
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. ll a[2200][2200];
  6. int main()
  7. {
  8. ios_base::sync_with_stdio(0);
  9. cin.tie(0);
  10. cout.tie(0);
  11.  
  12. test
  13. {
  14. ll n,i,j,k,l,c,b,d,z,y,x;
  15. cin>>d;
  16. cin>>n;
  17. while(n--)
  18. {
  19. cin>>x>>y>>z;
  20. for(i=x-d; i<=(x+d); i++)
  21. {
  22. for(j=y-d; j<=(y+d); j++)
  23. {
  24. if(i>=0 && i<=1025 && j>=0 && j<=1025)
  25. {
  26. a[i][j]+=z;
  27. }
  28. }
  29. }
  30. }
  31. l=0;
  32. c=b=0;
  33. for(i=0; i<=1025; i++)
  34. {
  35. for(j=0; j<=1025; j++)
  36. {
  37. if(a[i][j]>l)
  38. {
  39. l=a[i][j];
  40. c=i;
  41. b=j;
  42. }
  43. }
  44. }
  45. cout<<c<<" "<<b<<" "<<l<<endl;
  46. for(i=0;i<=1025;i++)
  47. {
  48. for(j=0;j<=1025;j++)
  49. {
  50. a[i][j]=0;
  51. }
  52. }
  53. }
  54.  
  55.  
  56. return 0;
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement