Submission #155950

#TimeUsernameProblemLanguageResultExecution timeMemory
155950MinnakhmetovOrchard (NOI14_orchard)C++14
8 / 25
1049 ms4180 KiB
#include <bits/stdc++.h> #define ll long long #define all(aaa) aaa.begin(), aaa.end() using namespace std; const int M1 = 1e6 + 5, INF = 1e9; int a[M1]; int solveForLine(int n, int m) { for (int i = 1; i <= m; i++) { cin >> a[i]; } for (int i = 1; i <= m; i++) { a[i] += a[i - 1]; } int ans = INF; for (int i = 0; i < m; i++) { for (int j = i; j <= m; j++) { ans = min(ans, a[m] + j - i - (a[j] - a[i]) * 2); } } return ans; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; if (n == 1) { cout << solveForLine(n, m); } 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...