Submission #300023

#TimeUsernameProblemLanguageResultExecution timeMemory
300023ryuku1110Preokret (COCI19_preokret)C++14
50 / 50
1 ms384 KiB
#include <bits/stdc++.h> #define pb push_back using namespace std; typedef long long ll; int n, city = 0, oppo = 0, d[252], TIE = 1, z[251]; int main() { //freopen(".INP", "r", stdin); //freopen(".OUT", "w", stdout); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; for (int i = 1; i <= n; ++ i) { cin >> z[i]; if (z[i] == 1) ++ city; else ++ oppo; if (city == oppo) ++ TIE; d[i] = city - oppo; } bool started = false; int st, en, ans = 0; z[n+1] = 2; for (int i = 1; i <= n; ++ i) { // cout << z[i] << " "; if (z[i] == 1 && started == false) { started = true; st = i; } if (z[i + 1] == 2 && started == true) { started = false; en = i; if (d[st - 1] < 0 && d[en] > 0) { ans = max(ans, en - st + 1); } } } z[n+1] = 1; started = false; for (int i = 1; i <= n; ++ i) { if (z[i] == 2 && started == false) { started = true; st = i; } if (z[i + 1] == 1 && started == true) { started = false; en = i; // cout << st << " " << en << endl; if (d[st - 1] > 0 && d[en] < 0) { ans = max(ans, en - st + 1); } } } cout << city << " " << oppo << endl; cout << TIE << endl; cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...