Submission #124529

#TimeUsernameProblemLanguageResultExecution timeMemory
124529johuthaOrchard (NOI14_orchard)C++14
13 / 25
278 ms15992 KiB
#include <iostream> #include <vector> #define int int64_t using namespace std; struct orchard { vector<vector<int>> orchard; int n, m; int calc() { for (int i = 0; i < n; i++) { int currsum = 0; int mmin = 0; int mp = -1; int mdiff = 0; int msp = 0; int me = 0; for (int j = 0; j < m; j++) { currsum += (orchard[i][j]) - (!orchard[i][j]); if (currsum < mmin) { mmin = currsum; mp = j; } if (currsum - mmin > mdiff) { msp = mp; mdiff = currsum - mmin; me = j; } } currsum = 0; for (int j = 0; j < m; j++) { if (j <= msp || j > me) currsum += (orchard[i][j]); else currsum += (!orchard[i][j]); } return currsum; } } }; signed main() { int n, m; cin >> n >> m; orchard orch; orch.n = n; orch.m = m; orch.orchard.resize(n, vector<int>(m)); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> orch.orchard[i][j]; } } cout << orch.calc() << "\n"; }

Compilation message (stderr)

orchard.cpp: In member function 'int64_t orchard::calc()':
orchard.cpp:47:5: warning: control reaches end of non-void function [-Wreturn-type]
     }
     ^
#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...