Logo
(追記) (追記ここまで)

22927번 - Mountainous Palindromic Subarray 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB (추가 메모리 없음)113625459.341%

문제

An array is Mountainous if it is strictly increasing, then strictly decreasing. Note that Mountainous arrays must therefore be of length three or greater.

A Subarray is defined as an array that can be attained by deleting some prefix and suffix (possibly empty) from the original array.

An array or subarray is a Palindrome if it is the same sequence forwards and backwards.

Given an array of integers, compute the length of the longest Subarray that is both Mountainous and a Palindrome.

입력

The first line of input contains an integer $n$ (1ドル \le n \le 10^6$), which is the number of integers in the array.

Each of the next $n$ lines contains a single integer $x$ (1ドル \le x \le 10^9$). These values form the array. They are given in order.

출력

Output a single integer, which is the length of the longest Mountainous Palindromic Subarray, or $-1$ of no such array exists.

제한

예제 입력 1

8
2
1
2
3
2
1
7
8

예제 출력 1

5

예제 입력 2

5
2
5
8
7
2

예제 출력 2

-1

힌트

출처

ICPC > Regionals > North America > North America Championship > North America Championship 2021 F번

Camp > Petrozavodsk Programming Camp > Summer 2021 > Day 2: The American Contest F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /