Submission #94970

# Submission time Handle Problem Language Result Execution time Memory
94970 2019-01-26T07:10:54 Z karma Orchard (NOI14_orchard) C++11
0 / 25
54 ms 14072 KB
#include<bits/stdc++.h>
#define For(i, a, b)  for(int i = a, _b = b; i <= _b; ++i)
#define Ford(i, a, b) for(int i = a, _b = b; i >= _b; --i)
#define FileName      "test"
#define ll            long long
#define ld            long double
#define ull           unsigned long long
#define Print(x)      cerr << #x << "is " << x << '\n';
#define pb            push_back
#define X             first
#define Y             second
//#define Karma

using namespace std;

template<typename T> inline void Cin(T &x)
{
    char c;
    T sign = 1;
    x = 0;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        if (c == '-') sign = -1;
    for (; c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    x *= sign;
}
template <typename T> inline void Out(T x) {if(x > 9) Out(x / 10); putchar(x % 10 + '0');}
template <typename T> inline void Cout(T x, char c) {if(x < 0) putchar('-'); x = abs(x); Out(x); putchar(c);}
template <typename T, typename... Args> inline void Cin(T& a, Args&... args) {Cin(a);Cin(args...);}
template <typename T, typename... Args> inline void Cout(T a, char c, Args... args) {Cout(a, c);Cout(args...);}

typedef pair<int, int> pii;
typedef pair<ll, int> plli;

int n, m, res = 0, x;
vector<int> h;

void Maximize()
{
    vector<int> l, r, q;
    l.resize(m, -1), r.resize(m, m);
    for(int i = 0; i < m; ++i) {
       while(q.size() && h[q.back()] >= h[i]) q.pop_back();
       if(q.size()) l[i] = q.back();
       q.emplace_back(i);
    }
    q.clear();
    for(int i = m - 1; i >= 0; --i) {
       while(q.size() && h[q.back()] >= h[i]) q.pop_back();
       if(q.size()) r[i] = q.back();
       q.emplace_back(i);
       res = max(res, (r[i] - l[i] - 1) * h[i]);
    }
}

void Enter()
{
     Cin(n, m);
     h.resize(m, 0);
     for(int i = 0; i < n; ++i) {
        for(int j = 0; j < m; ++j) {
            Cin(x);
            x? ++h[j]: h[j] = 0;
        }
        Maximize();
     }
     cout << res;
}

void Solve()
{

}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef Karma
    freopen(FileName".inp", "r", stdin);
    freopen(FileName".out", "w", stdout);
#endif // Karma

    Enter();
    Solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 14072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 1912 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 1964 KB Output isn't correct
2 Halted 0 ms 0 KB -