# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
831727 | Chal1shkan | Preokret (COCI19_preokret) | C++14 | 1 ms | 324 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Bismillahir-Rahmanir-Rahim
# include <bits/stdc++.h>
# define pb push_back
# define ff first
# define ss second
# define nl "\n"
# define sz(x) ((int)(x).size())
# define all(x) (x).begin(), (x).end()
# define deb(x) cerr << #x << " = " << x << endl;
# define pll pair <ll, ll>
# define pii pair <int, int>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll maxn = 1e6 + 7;
const ll inf = 2e18 + 0;
const ll mod = 1e9 + 7;
const ll dx[] = {-1, 1, 0, 0};
const ll dy[] = {0, 0, -1, 1};
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void ma1n (/* SABR */) {
ll n;
cin >> n;
ll a[n + 3];
for (ll i = 1; i <= n; ++i) cin >> a[i];
ll cnt1 = 0, cnt2 = 0;
ll ans1 = 1, ans2 = 0;
for (ll i = 1; i <= n; ++i) {
if (a[i] == 1) {
cnt1++;
}
if (a[i] == 2) {
cnt2++;
}
ans1 += (cnt1 == cnt2);
if (cnt1 != cnt2) {
ll x;
if (cnt1 < cnt2) {
x = 1;
}
else {
x = 2;
}
ll j = i;
while (j + 1 <= n && a[j + 1] == x) ++j;
ans2 = max(ans2, j - i);
}
}
cout << cnt1 << ' ' << cnt2 << nl;
cout << ans1 << nl << ans2 << nl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
// freopen("file.in", "r", stdin);
// freopen("file.out", "w", stdout);
int ttt = 1;
// cin >> ttt;
for (int test = 1; test <= ttt; ++test) {
// cout << "Case " << test << ":" << '\n';
ma1n();
}
return 0;
}
// 998batrr | BbIWEJI 3A TObOU!!!
// tourist | BbIWEJI 3A TObOU!!!
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |