Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <string>
  4. #include <algorithm>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <ctype.h>
  8. #include <sstream>
  9. #include <map>
  10. #include <queue>
  11. #include <set>
  12. #include <vector>
  13. #include <stack>
  14. #include <cstdio>
  15. #include <fstream>
  16.  
  17. //#include <bits/stdc++.h>
  18. using namespace std;
  19. #define fastIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
  20. #define ll long long
  21. #define mp make_pair
  22. #define mod (ll)1000000007
  23. #define inf 1e17
  24. #define PI acos(-1)
  25.  
  26. int t;
  27. int n, m, k;
  28. int x[111][111];
  29. int pre[111][111];
  30.  
  31. int ch(int i, int j, int h, int w) {
  32. return pre[h][w] - pre[i - 1][w] - pre[h][j - 1] + pre[i - 1][j - 1];
  33. }
  34. int cal(int i, int j, int h, int w){
  35. return (h - i + 1)*(w - j + 1);
  36. }
  37. int main()
  38. {
  39. fastIO;
  40. cin >> t;
  41. while (t--){
  42. cin >> n >> m >> k;
  43. for (int i = 1; i <= n; i++){
  44. for (int j = 1; j <= m; j++){
  45. cin >> x[i][j];
  46. pre[i][j] = x[i][j] + pre[i][j - 1];
  47. }
  48. }
  49. for (int i = 1; i <= n; i++){
  50. for (int j = 1; j <= m; j++){
  51. pre[i][j] += pre[i - 1][j];
  52. }
  53. }
  54. int mx = 0;
  55. for (int i = 1; i <= n; i++){
  56. for (int j = 1; j <= m; j++){
  57. for (int i1 = i; i1 <= n; i1++){
  58. for (int j1 = j; j1 <= m; j1++){
  59. if (ch(i, j, i1, j1) <= k){
  60. int temp = cal(i, j, i1, j1);
  61. if (mx < temp){
  62. mx = temp;
  63. }
  64. }
  65. }
  66. }
  67. }
  68. }
  69. cout << mx << endl;
  70. }
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement