Submission #933108

# Submission time Handle Problem Language Result Execution time Memory
933108 2024-02-25T04:38:16 Z sleepntsheep Luxury burrow (IZhO13_burrow) C
100 / 100
450 ms 18000 KB
#include<stdio.h>
int hi(int a,int b){return a>b?a:b;}
int sz,n,m,k,a[1002][1002],b[1002][1002],st[1002],top,nl[1002],pl[1002];
int ok(int lo)
{
    for(int i=0;i++<n;)for(int j=0;j++<m;)b[i][j]=a[i][j]>=lo;
    for(int i=0;i++<n;)for(int j=0;j++<m;)
        if(b[i][j])b[i][j]+=b[i-1][j];
    int hisz=0;
    for(int i=0;i++<n;)
    {
        int*h=b[i];
        for(int j=0;j++<m;)
        {
            while(top&&h[j]<h[st[top]])nl[st[top--]]=j;
            st[++top]=j;
        }
        while(top)nl[st[top--]]=m+1;
        for(int j=m;j>=1;--j)
        {
            while(top&&h[j]<h[st[top]])pl[st[top--]]=j;
            st[++top]=j;
        }
        while(top)pl[st[top--]]=0;
        for(int j=0;j++<m;)
            hisz=hi(hisz,h[j]*(nl[j]-pl[j]-1));
    }
    return hisz>=k?sz=hisz,1:0;
}

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for(int i=0;i++<n;)for(int j=0;j++<m;)scanf("%d",a[i]+j);

    ok(10);
    int l=0,r=1e9;
    while(l<=r){
        int y=(l+r)/2;
        if(ok(y))l=y+1;else r=y-1;
    }
    printf("%d %d",l-1,sz);
}

Compilation message

burrow.c: In function 'main':
burrow.c:33:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     scanf("%d%d%d",&n,&m,&k);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~
burrow.c:34:43: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |     for(int i=0;i++<n;)for(int j=0;j++<m;)scanf("%d",a[i]+j);
      |                                           ^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 2 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 4 ms 2908 KB Output is correct
9 Correct 6 ms 3164 KB Output is correct
10 Correct 23 ms 3416 KB Output is correct
11 Correct 34 ms 3932 KB Output is correct
12 Correct 19 ms 7768 KB Output is correct
13 Correct 24 ms 3160 KB Output is correct
14 Correct 57 ms 8284 KB Output is correct
15 Correct 58 ms 8284 KB Output is correct
16 Correct 63 ms 8772 KB Output is correct
17 Correct 63 ms 8028 KB Output is correct
18 Correct 158 ms 10320 KB Output is correct
19 Correct 177 ms 9432 KB Output is correct
20 Correct 384 ms 13144 KB Output is correct
21 Correct 334 ms 14124 KB Output is correct
22 Correct 399 ms 17948 KB Output is correct
23 Correct 450 ms 18000 KB Output is correct
24 Correct 282 ms 10924 KB Output is correct
25 Correct 289 ms 11092 KB Output is correct