Submission #78666

#TimeUsernameProblemLanguageResultExecution timeMemory
78666thebesOrchard (NOI14_orchard)C++14
25 / 25
231 ms13604 KiB
#include <bits/stdc++.h>
using namespace std;

const int MN = 155;
int ans[MN][MN], n, m, i, j, k, x, y, tot, opt;
bitset<100005> arr[MN];

int main(){
    for(scanf("%d%d",&n,&m),i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            scanf("%d",&x);
            arr[i][j] = (x);
            if(x) tot++;
        }
    }
    for(i=1;i<=m;i++){
        for(j=1;j<=n;j++){
            int tmp = 0;
            for(k=j;k<=n;k++){
                tmp+=(arr[k][i])? 1:-1;
                ans[j][k]=max(ans[j][k]+tmp,0);
                opt = max(opt, ans[j][k]);
            }
        }
    }
    printf("%d\n",tot-opt);
    return 0;
}

Compilation message (stderr)

orchard.cpp: In function 'int main()':
orchard.cpp:9:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(scanf("%d%d",&n,&m),i=1;i<=n;i++){
         ~~~~~~~~~~~~~~~~~~~^~~~
orchard.cpp:11:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&x);
             ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...