結果
問題 | No.1630 Sorting Integers (Greater than K) |
ユーザー | とりゐ |
提出日時 | 2021-07-15 15:12:11 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 831 bytes |
コンパイル時間 | 368 ms |
コンパイル使用メモリ | 86,732 KB |
実行使用メモリ | 84,848 KB |
最終ジャッジ日時 | 2023-10-14 02:17:47 |
合計ジャッジ時間 | 4,306 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 73 ms
70,972 KB |
testcase_01 | AC | 74 ms
71,016 KB |
testcase_02 | WA | - |
testcase_03 | AC | 75 ms
71,128 KB |
testcase_04 | AC | 73 ms
71,080 KB |
testcase_05 | AC | 75 ms
71,328 KB |
testcase_06 | AC | 73 ms
70,796 KB |
testcase_07 | AC | 72 ms
70,920 KB |
testcase_08 | AC | 74 ms
71,248 KB |
testcase_09 | AC | 75 ms
71,084 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 80 ms
75,356 KB |
testcase_23 | AC | 77 ms
72,396 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 103 ms
78,628 KB |
ソースコード
n,k=map(str,input().split()) n=int(n) c=list(map(int,input().split())) ans='-1' if len(k)>n: print(-1) exit() x='' for i in range(9): x+=str(i+1)*c[i] if len(k)<n: print(x) exit() flag=True memo=-1 memo2=0 for i in range(n): if flag: if int(k[i])<int(x[i]): print(x) exit() if int(k[i])>int(x[i]): flag=False flag=True d=c.copy() for i in range(n): if flag: if k[i]=='0': flag=False elif c[int(k[i])-1]==0: flag=False flag2=True for j in range(int(k[i]),9): if flag2 and c[j]>0: memo=i memo2=j flag2=False c[int(k[i])-1]-=1 #print(ans,i,c) tmp=k[:memo]+str(memo2+1) for i in range(memo): d[int(k[i])-1]-=1 d[memo2]-=1 for h in range(9): if memo2==h: tmp+=str(h+1)*(d[h]-1) else: tmp+=str(h+1)*d[h] print(tmp)