fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. short t, n;
  8.  
  9. while (t--)
  10. {
  11. cin >> n;
  12.  
  13. int arr[n][n];
  14.  
  15. for (int i = 0; i < n; i++)
  16. {
  17. for (int j = 0; j < n; j++)
  18. {
  19. cin >> arr[i][j];
  20. }
  21. }
  22.  
  23.  
  24. for (int k = 1 - n; k < n; k++)
  25. {
  26. vector <int> x;
  27. short l = 0;
  28. int sum = 0;
  29. for (int i = 0; i < n; i++)
  30. {
  31. while(i+k<n)
  32. {
  33. x[l]=arr[i][i + k];
  34. l++;
  35. }
  36.  
  37. }
  38. for (int z = 1; z < l; z++)
  39. {
  40. if (x[0] > x[z])
  41. {
  42. x[0] = x[z];
  43. }
  44. }
  45. if (x[0] < 0)
  46. {
  47. sum += -x[0];
  48. }
  49. cout << sum << endl;
  50.  
  51. }
  52.  
  53. }
  54. }
Success #stdin #stdout 0.01s 5292KB
stdin
4
1
1
2
-1 2
3 0
3
1 2 3
-2 1 -1
0 0 -1
5
1 1 -1 -1 3
-3 1 4 4 -4
-1 -1 3 0 -5
4 5 3 -3 -1
3 1 -3 -1 5
stdout
Standard output is empty