結果

問題 No.1368 サイクルの中に眠る門松列
コンテスト
ユーザー lloyz
提出日時 2022-06-02 21:33:06
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 489 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,329 ms
コンパイル使用メモリ 85,468 KB
実行使用メモリ 106,116 KB
最終ジャッジ日時 2026-04-09 10:07:57
合計ジャッジ時間 1,950 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 1 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

t = int(input())
for _ in range(t):
    n = int(input())
    A = list(map(int, input().split()))
    setA = set(A)
    if 1 <= len(setA) <= 2:
        print(0)
        continue
    maxA = max(A)
    for i in range(n):
        if A[i] == maxA:
            f = i
            break
    ans = sorted(setA, reverse=True)[1]
    for i in range(1, n):
        idx = (f + i) % n
        if A[idx] == maxA:
            continue
        if A[idx - 1] < A[idx]:
            ans = maxA
    print(ans)
0