tuki2501

land.cpp

Nov 29th, 2021
695
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. // ----------- define --------------
  5. #define int long long
  6. #define vi vector<int>
  7. #define ii pair<int,int>
  8. #define fi first
  9. #define sc second
  10. #define mp make_pair
  11. #define pqueue priority_queue
  12. #define popcnt __builtin_popcount
  13. #define getBit(x, k) ((x >> k) & 1)
  14. #define xorBit(x, k) (x ^ (1 << k))
  15. #define siz(x) (int)((x).size())
  16. #define all(x) (x).begin(),(x).end()
  17. // ---------------------------------
  18.  
  19. void Main() {
  20.   int n, m, s;
  21.   cin >> n >> m >> s;
  22.   vector<vi> a(n + 1, vi(m + 1));
  23.   for (int i = 1; i <= n; i++)
  24.   for (int j = 1; j <= m; j++) {
  25.     cin >> a[i][j];
  26.     a[i][j] += a[i - 1][j];
  27.   }
  28.   int ans = 0;
  29.   for (int i = 1; i <= n; i++)
  30.   for (int j = i; j <= n; j++) {
  31.     int sum = 0, l = 1;
  32.     for (int k = 1; k <= m; k++) {
  33.       sum += a[j][k] - a[i - 1][k];
  34.       while (sum > s) {
  35.         sum -= a[j][l] - a[i - 1][l];
  36.         l++;
  37.       }
  38.       ans = max(ans, (j - i + 1) * (k - l + 1));
  39.     }
  40.   }
  41.   cout << ans << '\n';
  42. }
  43.  
  44. signed main() {
  45.   freopen("LAND.inp", "r", stdin );
  46.   freopen("LAND.out", "w", stdout);
  47.   cin.tie(0)->sync_with_stdio(0);
  48.   int T = 1;
  49.   // cin >> T;
  50.   while (T--) Main();
  51. }
RAW Paste Data