Submission #5268

#TimeUsernameProblemLanguageResultExecution timeMemory
5268tncks0121Orchard (NOI14_orchard)C++98
13 / 25
124 ms12804 KiB
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <string.h> #include <memory.h> #include <math.h> #include <assert.h> #include <stack> #include <queue> #include <map> #include <set> #include <algorithm> #include <string> #include <functional> #include <vector> #include <deque> #include <utility> #include <bitset> #include <limits.h> #include <time.h> using namespace std; typedef long long ll; typedef unsigned long long llu; typedef double lf; typedef unsigned int uint; typedef long double llf; typedef pair<int, int> pii; int N, M; namespace single_row { const int M_ = 1000005; const int LEAF = 1048576; int A[M_], S[M_]; int T[M_]; void solve() { for(int i = 1; i <= M; i++) scanf("%d", A+i), S[i] = S[i-1] + A[i]; T[M+1] = (int)1e9; for(int j = M; j > 0; j--) T[j] = min(T[j+1], j - 2*S[j]); ll res = N*M; for(int i = 1; i <= M; i++) { res = min(res, (ll)S[M] - (i-1) + 2*S[i-1] + T[i]); } printf("%lld\n", res); } }; int main() { scanf("%d%d", &N, &M); if(N == 1) { single_row::solve(); }else { } 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...