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;
orta.ff = i / 2;
orta.ss = (i + 1) / 2;
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;
//}
Compilation message (stderr)
sequence.cpp: In function 'int sequence(int, std::vector<int>)':
sequence.cpp:43:1: warning: no return statement in function returning non-void [-Wreturn-type]
43 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |