Submission #197523

# Submission time Handle Problem Language Result Execution time Memory
197523 2020-01-21T13:32:26 Z handlename Orchard (NOI14_orchard) C++17
25 / 25
178 ms 18040 KB
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    int arr[n+1][m+1],total=0;
    memset(arr,0,sizeof(arr));
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            cin>>arr[i][j];
            if (arr[i][j]==0) arr[i][j]=-1;
            else total++;
        }
    }
    int pre[n+1][m+1];
    memset(pre,0,sizeof(pre));
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            pre[i][j]=pre[i-1][j]+arr[i][j];
        }
    }
    int maxi=0;
    for (int i=1;i<=n;i++){
        for (int j=i;j<=n;j++){
            int currentsum=0;
            for (int k=1;k<=m;k++){
                currentsum+=pre[j][k]-pre[i-1][k];
                maxi=max(maxi,currentsum);
                if (currentsum<0) currentsum=0;
            }
        }
    }
    cout<<total-maxi;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 412 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 760 KB Output is correct
2 Correct 3 ms 632 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 88 ms 18040 KB Output is correct
2 Correct 89 ms 18040 KB Output is correct
3 Correct 93 ms 17932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 3064 KB Output is correct
2 Correct 19 ms 3064 KB Output is correct
3 Correct 19 ms 3064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 392 KB Output is correct
2 Correct 8 ms 504 KB Output is correct
3 Correct 7 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 178 ms 7940 KB Output is correct
2 Correct 177 ms 7848 KB Output is correct
3 Correct 177 ms 7800 KB Output is correct