Submission #229226

#TimeUsernameProblemLanguageResultExecution timeMemory
229226VEGAnnPreokret (COCI19_preokret)C++14
50 / 50
5 ms384 KiB
#include <bits/stdc++.h> using namespace std; const int N = 310; int a[N], kl = 0, ans = 1, n, sch[N][2]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); // freopen("in.txt","r",stdin); cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; kl += bool(a[i] == 1); sch[i][0] = kl; sch[i][1] = i + 1 - kl; if (kl == i + 1 - kl) ans++; } cout << kl << " " << n - kl << '\n'; cout << ans << '\n'; ans = 0; for (int tp = 0; tp < 2; tp++) for (int i = 0; i < n; i++){ if (sch[i][tp] <= sch[i][tp ^ 1]) continue; int len = 1; for (int j = i + 1; j < n; j++){ if (sch[j][tp] != sch[j - 1][tp]) break; len++; } if (sch[i + len - 1][tp ^ 1] > sch[i][tp]) ans = max(ans, len - 1); } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...