# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
982100 | vjudge1 | 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 <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;
int sequence(int n, vector <int> a){
//unos y tres
int current = 0, sup = 0, dos = 0;
for(int i=0; i<n; i++){
if(a[i] == 1){
if(current+1>=0) {
current++;
sup++;
}
else {
current=1;
sup = 1;
}
}
else current--;
ans = max(sup, ans);
}
sup = current = 0;
for(int i=0; i<n; i++){
if(a[i] == 3){
if(current+1>=0) {
current++;
sup++;
}
else {
current=1;
sup = 1;
}
}
else current--;
ans = max(sup, ans);
}
for(int i=0; i<n; i++)
if(a[i] == 2) dos++;
return max(dos, ans);
}