Submission #837122

#TimeUsernameProblemLanguageResultExecution timeMemory
837122kebineOrchard (NOI14_orchard)C++17
13 / 25
50 ms11988 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define ull unsigned long long #define pii pair<int, int> #define pll pair<ll, ll> #define fi first #define se second const int N = 2e5 + 5; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m, ans = 0; cin >> n >> m; vector<vector<int>> a(n + 1, vector<int>(m + 1)); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; if (a[i][j] == 1) ans--; else a[i][j] = -1; } } if (n == 1) { int mx = 0, sum = 0; for (int i = 1; i <= m; i++) { sum = max(0, sum + a[1][i]); mx = max(mx, sum); } cout << -1 * (ans + mx) << "\n"; } }
#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...