結果

問題 No.1630 Sorting Integers (Greater than K)
ユーザー PSL24251284PSL24251284
提出日時 2021-07-31 04:14:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 590 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 269,844 KB
最終ジャッジ日時 2023-10-14 13:30:35
合計ジャッジ時間 5,603 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
78,296 KB
testcase_01 WA -
testcase_02 AC 71 ms
71,396 KB
testcase_03 AC 74 ms
71,332 KB
testcase_04 AC 70 ms
71,340 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = input().split()
c = [0] + list(map(int,input().split()))
N = int(N)
if len(K) > N:
    print(-1)
    exit()
for i in range(N-len(K)):
    K = "0" + K
#print(K)
a = ""
for i0 in range(10):
    for j in range(c[i0]):
        a = a + str(i0)
ans = [a]
s = ""
for i in range(N):
    v = int(K[i])
    if c[v]:
        s = s + str(v)
        c[v] -= 1
        a = s
        for i0 in range(10):
            for j in range(c[i0]):
                a = a + str(i0)
        ans.append(a)
    else:
        break
#print(ans)
for v in ans:
    if K < v:
        print(v)
        exit()
print(-1)
0