結果

問題 No.1537 私の代わりに仕事やっといてください。
ユーザー ygd.
提出日時 2021-06-12 21:03:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 663 ms / 2,000 ms
コード長 884 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 121,184 KB
最終ジャッジ日時 2024-12-17 18:53:24
合計ジャッジ時間 2,704 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

def main():
    N = int(input())
    A = list(map(int,input().split()))
    Z = []
    for i,a in enumerate(A):
        Z.append((a,i+1)) #1-index
    Z.sort()
    ans = []
    idx = 0
    while True:
        ans.append(Z[idx][1])
        if idx + 2 < N:
            idx += 2
            Flag = 0
        elif idx + 1 < N:
            idx += 1
            Flag = 1
        else:
            break
    if Flag == 0:
        idx -= 1
    else:
        idx -= 2
    while True:
        ans.append(Z[idx][1])
        if idx - 2 >= 0:
            idx -= 2
        elif idx - 1 >= 0:
            idx -= 1
        else:
            break

    #print(ans)
    ans.pop() #最後の2回目は不要
    ret = deque(ans)
    while ret[0] != 1:
        v = ret.popleft()
        ret.append(v)
    ret.append(1)
    print(*ret)

if __name__ == '__main__':
    main()
0