Submission #97449

# Submission time Handle Problem Language Result Execution time Memory
97449 2019-02-16T09:01:44 Z Kastanda Luxury burrow (IZhO13_burrow) C++11
100 / 100
493 ms 14172 KB
// I do it for the glory
#include<bits/stdc++.h>
using namespace std;
const int N = 1009;
int n, m, k, L[N], R[N], A[N][N], up[N];
inline int Solve(int X)
{
    int MX = 0;
    memset(up, 0, sizeof(up));
    for (int i = 1; i <= n; i++)
    {
        up[0] = up[m + 1] = -1;
        for (int j = 1; j <= m; j++)
            up[j] = (A[i][j] < X) ? (0) : (up[j] + 1);
        for (int j = 1; j <= m; j++)
        {
            L[j] = j - 1;
            while (up[L[j]] >= up[j])
                L[j] = L[L[j]];
        }
        for (int j = m; j; j--)
        {
            R[j] = j + 1;
            while (up[R[j]] >= up[j])
                R[j] = R[R[j]];
            MX = max(MX, (R[j] - L[j] - 1) * up[j]);
        }
    }
    return MX;
}
int main()
{
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            scanf("%d", &A[i][j]);
    int le = 0, ri = 1e9 + 7, md;
    while (ri - le > 1)
    {
        md = (le + ri) >> 1;
        if (Solve(md) >= k)
            le = md;
        else
            ri = md;
    }
    return !printf("%d %d\n", le, Solve(le));
}

Compilation message

burrow.cpp: In function 'int main()':
burrow.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &n, &m, &k);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
burrow.cpp:36:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &A[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 8 ms 768 KB Output is correct
9 Correct 10 ms 1280 KB Output is correct
10 Correct 27 ms 1408 KB Output is correct
11 Correct 42 ms 1920 KB Output is correct
12 Correct 29 ms 2432 KB Output is correct
13 Correct 34 ms 1188 KB Output is correct
14 Correct 76 ms 2556 KB Output is correct
15 Correct 90 ms 2656 KB Output is correct
16 Correct 72 ms 3064 KB Output is correct
17 Correct 90 ms 2808 KB Output is correct
18 Correct 200 ms 5656 KB Output is correct
19 Correct 222 ms 4984 KB Output is correct
20 Correct 472 ms 9212 KB Output is correct
21 Correct 485 ms 10104 KB Output is correct
22 Correct 493 ms 14072 KB Output is correct
23 Correct 471 ms 14172 KB Output is correct
24 Correct 381 ms 7048 KB Output is correct
25 Correct 439 ms 7288 KB Output is correct