結果

問題 No.1061 素敵な数列
ユーザー kimiyukikimiyuki
提出日時 2020-05-23 00:22:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 229 ms / 2,000 ms
コード長 1,214 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 22,260 KB
最終ジャッジ日時 2024-04-15 20:08:12
合計ジャッジ時間 6,022 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
11,520 KB
testcase_01 AC 34 ms
11,520 KB
testcase_02 AC 35 ms
11,520 KB
testcase_03 AC 37 ms
11,520 KB
testcase_04 AC 34 ms
11,648 KB
testcase_05 AC 35 ms
11,520 KB
testcase_06 AC 35 ms
11,520 KB
testcase_07 AC 35 ms
11,648 KB
testcase_08 AC 36 ms
11,520 KB
testcase_09 AC 34 ms
11,648 KB
testcase_10 AC 34 ms
11,520 KB
testcase_11 AC 34 ms
11,520 KB
testcase_12 AC 35 ms
11,520 KB
testcase_13 AC 36 ms
11,648 KB
testcase_14 AC 35 ms
11,520 KB
testcase_15 AC 34 ms
11,520 KB
testcase_16 AC 36 ms
11,520 KB
testcase_17 AC 35 ms
11,520 KB
testcase_18 AC 35 ms
11,648 KB
testcase_19 AC 84 ms
14,624 KB
testcase_20 AC 77 ms
14,140 KB
testcase_21 AC 131 ms
17,032 KB
testcase_22 AC 217 ms
21,368 KB
testcase_23 AC 173 ms
19,168 KB
testcase_24 AC 173 ms
19,212 KB
testcase_25 AC 169 ms
19,220 KB
testcase_26 AC 65 ms
13,536 KB
testcase_27 AC 113 ms
15,792 KB
testcase_28 AC 124 ms
16,576 KB
testcase_29 AC 164 ms
18,720 KB
testcase_30 AC 191 ms
20,364 KB
testcase_31 AC 119 ms
16,196 KB
testcase_32 AC 229 ms
22,260 KB
testcase_33 AC 66 ms
13,492 KB
testcase_34 AC 82 ms
14,304 KB
testcase_35 AC 78 ms
14,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
from typing import *

def solve(n: int) -> List[int]:
    al = []
    ar = []
    bl = []
    br = [n - 1]
    cl = []
    cr = [n - 1, n - 1]
    remaining = n - 1
    remaining -= (n - 1) // 3 * 2
    remaining -= max(0, (n - 1) % 3 - 1)
    for i in range(n - 1):
        if i % 3 == 0:
            al += [i]
            ar += [i, i]
        elif i % 3 == 1:
            if remaining >= 1:
                bl += [i]
                br += [i, i]
                remaining -= 1
            else:
                bl += [i, i]
                br += [i]
        else:
            if remaining >= 1:
                cl += [i, i]
                cr += [i]
                remaining -= 1
            else:
                cl += [i]
                cr += [i, i]
    if remaining != 0:
        return [-1]
    ans = []
    ans.extend(reversed(al))
    ans.extend(ar)
    ans.extend(reversed(bl))
    ans.extend(br)
    ans.extend(reversed(cl))
    ans.extend(cr)
    return ans

# generated by online-judge-template-generator v4.1.0 (https://github.com/kmyk/online-judge-template-generator)
def main():
    N = int(input())
    ans = solve(N)
    print(*ans)

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