# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1061429 | Halym2007 | Sequence (APIO23_sequence) | C++17 | 0 ms | 0 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.
#include <bits/stdc++.h>
//#include "sequence.h"
using namespace std;
#define ll long long
#define sz size()
#define ff first
#define ss second
#define pb push_back
#define pii pair <int, int>
const int N = 5e5 + 5;
int a[N], st[N], n, val[N], sana[N];
int sequence(int N, vector<int> A) {
n = N;
for (int i = 0; i < n; ++i) {
a[i] = A[i];
}
int jogap = 0;
int bir = 0, iki = 0, uc = 0;
for (int i = 0; i < n; ++i) {
if (a[i] == 1) {
bir++;
}
else if (a[i] == 2) {
iki++;
}
else uc++;
pii orta = ({i / 2 + 1, (i + 1) / 2 + 1});
if (bir >= orta.ff) {
jogap = max (jogap, bir);
}
else if (bir + iki >= orta.ff) {
jogap = max (jogap, iki);
}
else {
jogap = max (jogap, uc);
}
}
}
//int main() {
// freopen ("input.txt", "r", stdin);
// int N;
// assert(1 == scanf("%d", &N));
//
// std::vector<int> A(N);
// for (int i = 0; i < N; ++i) {
// assert(1 == scanf("%d", &A[i]));
// }
// int result = sequence(N, A);
// printf("%d\n", result);
// return 0;
//}