Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <string>
- #include <algorithm>
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <sstream>
- #include <map>
- #include <queue>
- #include <set>
- #include <vector>
- #include <stack>
- #include <cstdio>
- #include <fstream>
- //#include <bits/stdc++.h>
- using namespace std;
- #define fastIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
- #define ll long long
- #define mp make_pair
- #define mod (ll)1000000007
- #define inf 1e17
- #define PI acos(-1)
- int t;
- int n, m, k;
- int x[111][111];
- int pre[111][111];
- int ch(int i, int j, int h, int w) {
- return pre[h][w] - pre[i - 1][w] - pre[h][j - 1] + pre[i - 1][j - 1];
- }
- int cal(int i, int j, int h, int w){
- return (h - i + 1)*(w - j + 1);
- }
- int main()
- {
- fastIO;
- cin >> t;
- while (t--){
- cin >> n >> m >> k;
- for (int i = 1; i <= n; i++){
- for (int j = 1; j <= m; j++){
- cin >> x[i][j];
- pre[i][j] = x[i][j] + pre[i][j - 1];
- }
- }
- for (int i = 1; i <= n; i++){
- for (int j = 1; j <= m; j++){
- pre[i][j] += pre[i - 1][j];
- }
- }
- int mx = 0;
- for (int i = 1; i <= n; i++){
- for (int j = 1; j <= m; j++){
- for (int i1 = i; i1 <= n; i1++){
- for (int j1 = j; j1 <= m; j1++){
- if (ch(i, j, i1, j1) <= k){
- int temp = cal(i, j, i1, j1);
- if (mx < temp){
- mx = temp;
- }
- }
- }
- }
- }
- }
- cout << mx << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement