이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "sequence.h"
#include <bits/stdc++.h>
using namespace std;
int sequence(int N, std::vector<int> A) {
    #define int long long
    int ans = 0, tup = 1, tdown = 0;
    vector<pair<int, int>> up, down;
    bool f = true; // true -> up, false -> down
    up.push_back({A[0], 1});
    for(int i = 1; i < N; i++) {
        if(A[i] < A[i-1]) f = false;
        if(f) {
            if(A[i] == up.back().first) {
                up.back().second++;
            } else {
                up.push_back({A[i], 1});
            }
            tup++;
        } else {
            if(!down.empty() && A[i] == down.back().first) {
                down.back().second++;
            } else {
                down.push_back({A[i], 1});
            }
            tdown++;
        }
    }
    int i1 = 0, i2 = down.size()-1;
    while(i1 < up.size() && i2 >= 0) {
        if(up[i1].first < down[i2].first) {
            ans = max(ans, up[i1].second);
            tup -= up[i1].second;
            i1++;
        } else if(up[i1].first > down[i2].first) {
            ans = max(ans, down[i2].second);
            tdown -= down[i2].second;
            i2--;
        } else {
            ans = max(ans, up[i1].second);
            ans = max(ans, down[i2].second);
            if(tup+tdown-up[i1].second-down[i2].second <= N/2) ans = max(ans, up[i1].second+down[i2].second);
            tup -= up[i1].second;
            tdown -= down[i2].second;
            i1++;
            i2--;
        }
    }
    while(i1 < up.size()) {
        ans = max(ans, up[i1].second);
        i1++;
    }
    while(i2 >= 0) {
        ans = max(ans, down[i2].second);
        i2--;
    }
    return ans;
    #undef int
}
컴파일 시 표준 에러 (stderr) 메시지
sequence.cpp: In function 'int sequence(int, std::vector<int>)':
sequence.cpp:30:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     while(i1 < up.size() && i2 >= 0) {
      |           ~~~^~~~~~~~~~~
sequence.cpp:49:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     while(i1 < up.size()) {
      |           ~~~^~~~~~~~~~~| # | 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... |