結果

問題 No.1633 Sorting Integers (Multiple of 2^K)
ユーザー googol_S0googol_S0
提出日時 2021-07-30 21:17:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 999 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 86,612 KB
実行使用メモリ 276,684 KB
最終ジャッジ日時 2023-10-14 03:01:53
合計ジャッジ時間 23,518 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,148 KB
testcase_01 AC 78 ms
75,460 KB
testcase_02 AC 171 ms
78,572 KB
testcase_03 AC 73 ms
71,008 KB
testcase_04 AC 78 ms
75,464 KB
testcase_05 AC 72 ms
71,160 KB
testcase_06 AC 80 ms
76,196 KB
testcase_07 AC 75 ms
71,120 KB
testcase_08 WA -
testcase_09 AC 74 ms
71,068 KB
testcase_10 AC 73 ms
71,260 KB
testcase_11 AC 73 ms
71,424 KB
testcase_12 AC 74 ms
71,488 KB
testcase_13 AC 74 ms
71,396 KB
testcase_14 AC 72 ms
71,068 KB
testcase_15 AC 72 ms
71,160 KB
testcase_16 AC 73 ms
71,148 KB
testcase_17 AC 73 ms
71,316 KB
testcase_18 AC 74 ms
71,132 KB
testcase_19 AC 80 ms
75,704 KB
testcase_20 AC 80 ms
75,568 KB
testcase_21 AC 74 ms
70,992 KB
testcase_22 AC 77 ms
75,628 KB
testcase_23 WA -
testcase_24 AC 1,186 ms
275,440 KB
testcase_25 WA -
testcase_26 AC 1,038 ms
273,936 KB
testcase_27 WA -
testcase_28 AC 1,104 ms
275,160 KB
testcase_29 AC 1,168 ms
272,280 KB
testcase_30 AC 1,108 ms
273,236 KB
testcase_31 AC 1,405 ms
276,532 KB
testcase_32 WA -
testcase_33 AC 451 ms
112,332 KB
testcase_34 AC 237 ms
81,180 KB
testcase_35 AC 318 ms
91,604 KB
testcase_36 AC 272 ms
86,044 KB
testcase_37 AC 666 ms
172,020 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 248 ms
81,896 KB
testcase_41 AC 721 ms
182,232 KB
testcase_42 AC 243 ms
81,952 KB
testcase_43 AC 469 ms
116,356 KB
testcase_44 AC 998 ms
266,704 KB
testcase_45 WA -
testcase_46 AC 256 ms
84,224 KB
testcase_47 AC 317 ms
91,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
C=list(map(int,input().split()))
A=[]
for i in range(9):
  for j in range(C[i]):
    A.append(i+1)
ANS=0
M=(N+1)>>1
L=N>>1
t=0
for u in range(5,-1,-1):
  t+=(1<<u)
  mod=1<<t
  P=[pow(10,i,mod) for i in range(N+1)]
  DP=[set() for i in range(1<<N)]
  DP[0]=set([0])
  for i in range(1<<N):
    c=bin(i).count('1')
    if c>=L:
      x=((1<<N)-1)^i
      y=[0]*10
      for j in range(9):
        y[j+1]=y[j]+C[j]
      z=0
      p=0
      for k in range(N):
        while y[p]==k:
          p+=1
        if (x>>k)&1:
          z|=(1<<y[p-1])
          y[p-1]+=1
      x=z
      if len(DP[x])>0:
        for j in DP[i]:
          if (-j*P[N-c])%mod in DP[x]:
            ANS=t
            break
        if ANS==t:
          break
    if c>=M:
      continue
    for j in range(N):
      if (i>>j)&1:
        continue
      if j>0 and A[j-1]==A[j] and (i>>(j-1))&1==0:
        continue
      for k in DP[i]:
        DP[i|(1<<j)].add((k*10+A[j])%mod)
  if ANS<t:
    t-=(1<<u)
print(ANS)
0