結果

問題 No.1635 Let’s Sort Integers!!
ユーザー とりゐとりゐ
提出日時 2021-07-05 02:32:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 287 ms / 2,000 ms
コード長 1,060 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 86,872 KB
実行使用メモリ 194,440 KB
最終ジャッジ日時 2023-10-14 01:44:07
合計ジャッジ時間 24,837 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,032 KB
testcase_01 AC 72 ms
71,196 KB
testcase_02 AC 73 ms
71,000 KB
testcase_03 AC 76 ms
71,016 KB
testcase_04 AC 72 ms
71,004 KB
testcase_05 AC 72 ms
71,240 KB
testcase_06 AC 71 ms
70,996 KB
testcase_07 AC 70 ms
71,272 KB
testcase_08 AC 73 ms
71,004 KB
testcase_09 AC 72 ms
71,080 KB
testcase_10 AC 74 ms
70,876 KB
testcase_11 AC 72 ms
71,196 KB
testcase_12 AC 72 ms
71,072 KB
testcase_13 AC 73 ms
71,144 KB
testcase_14 AC 74 ms
70,872 KB
testcase_15 AC 73 ms
71,160 KB
testcase_16 AC 73 ms
71,004 KB
testcase_17 AC 72 ms
71,132 KB
testcase_18 AC 72 ms
71,112 KB
testcase_19 AC 73 ms
71,008 KB
testcase_20 AC 72 ms
71,080 KB
testcase_21 AC 72 ms
71,108 KB
testcase_22 AC 72 ms
71,200 KB
testcase_23 AC 73 ms
70,876 KB
testcase_24 AC 73 ms
70,984 KB
testcase_25 AC 72 ms
71,052 KB
testcase_26 AC 70 ms
71,036 KB
testcase_27 AC 72 ms
71,072 KB
testcase_28 AC 73 ms
71,312 KB
testcase_29 AC 71 ms
71,032 KB
testcase_30 AC 72 ms
71,128 KB
testcase_31 AC 72 ms
71,208 KB
testcase_32 AC 73 ms
71,052 KB
testcase_33 AC 73 ms
71,092 KB
testcase_34 AC 71 ms
71,004 KB
testcase_35 AC 72 ms
71,204 KB
testcase_36 AC 73 ms
71,088 KB
testcase_37 AC 71 ms
70,996 KB
testcase_38 AC 72 ms
71,108 KB
testcase_39 AC 72 ms
71,040 KB
testcase_40 AC 74 ms
71,036 KB
testcase_41 AC 72 ms
71,092 KB
testcase_42 AC 71 ms
71,012 KB
testcase_43 AC 72 ms
71,088 KB
testcase_44 AC 73 ms
71,112 KB
testcase_45 AC 75 ms
71,232 KB
testcase_46 AC 73 ms
71,032 KB
testcase_47 AC 71 ms
71,180 KB
testcase_48 AC 72 ms
71,032 KB
testcase_49 AC 75 ms
71,028 KB
testcase_50 AC 72 ms
70,996 KB
testcase_51 AC 77 ms
75,056 KB
testcase_52 AC 73 ms
71,196 KB
testcase_53 AC 74 ms
71,192 KB
testcase_54 AC 74 ms
71,072 KB
testcase_55 AC 76 ms
71,092 KB
testcase_56 AC 73 ms
71,224 KB
testcase_57 AC 77 ms
75,160 KB
testcase_58 AC 75 ms
71,104 KB
testcase_59 AC 73 ms
71,068 KB
testcase_60 AC 272 ms
194,128 KB
testcase_61 AC 283 ms
157,848 KB
testcase_62 AC 265 ms
176,492 KB
testcase_63 AC 285 ms
170,404 KB
testcase_64 AC 271 ms
147,492 KB
testcase_65 AC 209 ms
124,472 KB
testcase_66 AC 210 ms
124,404 KB
testcase_67 AC 210 ms
124,320 KB
testcase_68 AC 72 ms
71,132 KB
testcase_69 AC 72 ms
71,180 KB
testcase_70 AC 264 ms
194,440 KB
testcase_71 AC 282 ms
155,548 KB
testcase_72 AC 282 ms
159,264 KB
testcase_73 AC 287 ms
166,188 KB
testcase_74 AC 280 ms
159,972 KB
testcase_75 AC 207 ms
124,332 KB
testcase_76 AC 209 ms
124,308 KB
testcase_77 AC 211 ms
124,472 KB
testcase_78 AC 72 ms
71,212 KB
testcase_79 AC 71 ms
71,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(n,k):
  #n%2==1 and k>n*(n-1)//2
  if k>(n**2-3)//2:
    return [-1]
  ans=[0]*n
  m=(n**2-3)//2-k+n//2+2
  for i in range(n//2):
    if n//2+2+i==m:
      ans[2*i]=n//2+2
    else:
      ans[2*i]=n//2+2+i
    ans[2*i+1]=i+1
  ans[n-1]=n//2+1
  ans[0]=m
  return ans

def f2(n,k):
  #n%2==0 and k>n*(n-1)//2
  if k>n**2//2-1:
    return [-1]
  ans=[0]*n
  m=n**2//2-k+n//2
  for i in range(n//2):
    if n//2+1+i==m:
      ans[2*i]=n//2+1
    else:
      ans[2*i]=n//2+1+i
    ans[2*i+1]=i+1
  ans[0]=m
  return ans

def g(n,k):
  #k<=n*(n-1)//2
  used=[1]*(n+1)
  used[n]=0
  k-=n-1
  ans=[n]
  L=n
  for i in range(n-2):
    if i%2==0:
      a=i//2+2
    else:
      a=n-(i+1)//2
    if k>=abs(L-a):
      k-=abs(L-a)
      L=a
      used[a]=0
      ans.append(a)
  ans2=[]
  for i in range(1,n):
    if used[i]:
      ans2.append(i)
  return ans2+ans
n,k=map(int,input().split())
if k<n-1:
  print(-1)
elif n%2==1:
  if k>n*(n-1)//2:
    print(*f(n,k))
  else:
    print(*g(n,k))
else:
  if k>n*(n-1)//2:
    print(*f2(n,k))
  else:
    print(*g(n,k))
0