Submission #824643

#TimeUsernameProblemLanguageResultExecution timeMemory
824643exodus_Orchard (NOI14_orchard)C++14
25 / 25
327 ms14004 KiB
#include<bits/stdc++.h> #define FAST ios_base::sync_with_stdio(false); cin.tie(0); using namespace std; int main() { FAST int r,c; int hitone=0; cin >> r >> c; int orch[r+1][c+1]; for(int i=1; i<=r; i++) { for(int j=1; j<=c; j++) { cin >> orch[i][j]; if(orch[i][j]==1) hitone++; } } int answer = hitone; int ter, sum; vector<int>co(c+1); for(int i=1; i<=r; i++) { for(int k=1; k<=c; k++) { co[k]=0; } for(int j=i; j<=r; j++) { sum = 0; ter = 0; for(int kol=1; kol<=c; kol++) { if(orch[j][kol]) { sum-=1; } else { sum+=1; } co[kol]+=sum; answer = min(answer, hitone+co[kol]-ter); ter = max(ter, co[kol]); } } } cout << answer << endl; 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...