結果

問題 No.1635 Let’s Sort Integers!!
ユーザー とりゐとりゐ
提出日時 2021-06-12 05:54:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,611 bytes
コンパイル時間 517 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 207,100 KB
最終ジャッジ日時 2023-10-14 01:39:46
合計ジャッジ時間 27,997 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,300 KB
testcase_01 AC 73 ms
71,416 KB
testcase_02 AC 73 ms
71,300 KB
testcase_03 AC 73 ms
71,176 KB
testcase_04 AC 72 ms
71,428 KB
testcase_05 AC 74 ms
71,248 KB
testcase_06 AC 74 ms
71,436 KB
testcase_07 AC 73 ms
71,428 KB
testcase_08 AC 74 ms
71,188 KB
testcase_09 AC 74 ms
71,300 KB
testcase_10 AC 71 ms
71,288 KB
testcase_11 AC 72 ms
71,316 KB
testcase_12 AC 74 ms
71,288 KB
testcase_13 AC 71 ms
71,180 KB
testcase_14 AC 73 ms
71,368 KB
testcase_15 AC 72 ms
71,116 KB
testcase_16 AC 72 ms
71,284 KB
testcase_17 AC 74 ms
71,248 KB
testcase_18 AC 74 ms
71,216 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 75 ms
71,100 KB
testcase_28 AC 74 ms
71,368 KB
testcase_29 AC 73 ms
71,184 KB
testcase_30 AC 74 ms
71,292 KB
testcase_31 AC 74 ms
71,292 KB
testcase_32 AC 74 ms
71,424 KB
testcase_33 AC 75 ms
71,284 KB
testcase_34 AC 75 ms
71,248 KB
testcase_35 AC 75 ms
71,212 KB
testcase_36 AC 75 ms
71,428 KB
testcase_37 AC 74 ms
71,108 KB
testcase_38 AC 75 ms
71,328 KB
testcase_39 AC 72 ms
71,288 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 72 ms
71,220 KB
testcase_48 AC 75 ms
71,044 KB
testcase_49 AC 75 ms
71,040 KB
testcase_50 AC 75 ms
71,040 KB
testcase_51 AC 79 ms
75,256 KB
testcase_52 AC 74 ms
71,304 KB
testcase_53 AC 75 ms
71,424 KB
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 AC 73 ms
71,180 KB
testcase_60 AC 258 ms
187,820 KB
testcase_61 AC 319 ms
200,020 KB
testcase_62 AC 272 ms
170,280 KB
testcase_63 AC 284 ms
206,880 KB
testcase_64 AC 280 ms
181,664 KB
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 AC 74 ms
71,292 KB
testcase_69 AC 76 ms
71,276 KB
testcase_70 AC 265 ms
188,324 KB
testcase_71 AC 286 ms
193,440 KB
testcase_72 AC 280 ms
199,692 KB
testcase_73 AC 277 ms
207,100 KB
testcase_74 AC 284 ms
165,720 KB
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 AC 182 ms
71,252 KB
testcase_79 AC 73 ms
71,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def g(n,k):
  #k<=n*(n-1)//2
  used=[1]*(n+1)
  used[1]=0
  used[n]=0
  cnt=k-(n-1)
  ans=[]
  ans2=[n]
  a=n
  b=1
  for i in range(n-2):
    if cnt!=0:
      if i%2==0:
        if cnt<=(a-1)-b:
          used[b+cnt]=0
          ans.append(b+cnt)
          cnt=0
        else:
          a-=1
          ans.append(a)
          cnt-=a-b
          used[a]=0
      else:
        if cnt<=a-(b+1):
          used[a-cnt]=0
          ans.append(a-cnt)
          cnt=0
        else:
          b+=1
          cnt-=a-b
          used[b]=0
          ans.append(b)
  for i in range(n-1,1,-1):
    if used[i]:
      ans2.append(i)
  ans2.append(1)
  return ans2+ans

def h(x):
  cnt=0
  for i in range(len(x)-1):
    cnt+=(abs(x[i]-x[i+1]))
  return cnt
n,k=map(int,input().split())
if k<n-1:
  print(-1)
elif n%2==0:
  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