Submission #392873

#TimeUsernameProblemLanguageResultExecution timeMemory
392873strawberry2005Orchard (NOI14_orchard)C++17
25 / 25
161 ms17860 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define F first #define S second #define mp make_pair const int mod = 1e9+7; #define deb(x) cout<<#x<<": "<<x<<endl int iceil(int a, int b) { return (a + b - 1) / b; } int mul(int a, int b) { return a * 1ll * b % mod; } int binpow(int a, int b) { int res = 1; while (b) { if (b & 1) res = mul(res, a); a = mul(a, a); b >>= 1; } return res; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.precision(20); #ifdef strawberryshaker2005 freopen("input.txt", "r", stdin); #endif int n,m; cin>>n>>m; int grid[n+1][m+1];memset(grid,0,sizeof(grid)); int total=0; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ int temp; cin>>temp; total+=temp; if(temp==0) temp=-1; grid[i][j]=grid[i-1][j]+temp; } } int cur=0,sum=0; for(int i=1;i<=n;i++){ for(int j=i;j<=n;j++){ cur=0; for(int k=1;k<=m;k++){ cur+=grid[j][k]-grid[i-1][k]; sum=max(sum,cur); if(cur<0) cur=0; } } } cout<<total-sum; return(0); }
#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...