結果

問題 No.2719 Equal Inner Products in Permutation
ユーザー flygonflygon
提出日時 2024-04-06 14:10:58
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 751 bytes
コンパイル時間 501 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 130,900 KB
最終ジャッジ日時 2024-04-06 14:11:08
合計ジャッジ時間 8,876 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,724 KB
testcase_01 RE -
testcase_02 WA -
testcase_03 AC 42 ms
55,724 KB
testcase_04 AC 43 ms
55,724 KB
testcase_05 AC 42 ms
55,724 KB
testcase_06 AC 42 ms
55,724 KB
testcase_07 AC 42 ms
55,724 KB
testcase_08 AC 45 ms
55,724 KB
testcase_09 AC 42 ms
55,724 KB
testcase_10 AC 58 ms
68,740 KB
testcase_11 AC 58 ms
68,740 KB
testcase_12 AC 58 ms
68,740 KB
testcase_13 AC 57 ms
66,636 KB
testcase_14 AC 58 ms
68,740 KB
testcase_15 AC 158 ms
130,900 KB
testcase_16 AC 162 ms
129,160 KB
testcase_17 AC 133 ms
114,164 KB
testcase_18 AC 165 ms
128,928 KB
testcase_19 AC 150 ms
126,224 KB
testcase_20 AC 129 ms
110,232 KB
testcase_21 AC 166 ms
129,108 KB
testcase_22 AC 150 ms
120,108 KB
testcase_23 AC 137 ms
115,864 KB
testcase_24 AC 127 ms
109,460 KB
testcase_25 AC 170 ms
129,960 KB
testcase_26 AC 178 ms
129,960 KB
testcase_27 AC 167 ms
129,960 KB
testcase_28 AC 167 ms
129,960 KB
testcase_29 AC 166 ms
129,960 KB
testcase_30 AC 167 ms
129,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd

n = int(input())
a = []
b = [i+1 for i in range(n)]
c = []
for i in range(n):
    x,y = n+2*i+1, n+2*i+2
    a.append(x)
    c.append(y)


if n % 4 == 1 or n % 4 == 2:
    a[-1], c[-2] = c[-2], a[-1]
    g = (n*(n+1)//2 + 2*n - 1)//2
else:
    g = (n*(n+1)//2)//2
now = 0
for i in range(n)[::-1]:
    x,y = a[i],c[i]
    if abs(b[i]*(a[i]-c[i]))+now <= g:
        now += abs(b[i]*(a[i]-c[i]))
        a[i] = min(x,y)
        c[i] = max(x,y)
    else:
        a[i] = max(x,y)
        c[i] = min(x,y)
ans = a+b+c

print(*ans)



0