結果
問題 | No.1630 Sorting Integers (Greater than K) |
ユーザー | aaaaaaaaaa2230 |
提出日時 | 2021-07-30 22:39:24 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 705 bytes |
コンパイル時間 | 273 ms |
コンパイル使用メモリ | 86,980 KB |
実行使用メモリ | 268,616 KB |
最終ジャッジ日時 | 2023-10-14 06:26:08 |
合計ジャッジ時間 | 5,622 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 72 ms
75,436 KB |
testcase_01 | AC | 72 ms
71,192 KB |
testcase_02 | AC | 72 ms
71,528 KB |
testcase_03 | AC | 73 ms
71,308 KB |
testcase_04 | AC | 72 ms
71,352 KB |
testcase_05 | AC | 72 ms
71,200 KB |
testcase_06 | AC | 71 ms
71,176 KB |
testcase_07 | AC | 70 ms
71,452 KB |
testcase_08 | AC | 72 ms
71,280 KB |
testcase_09 | AC | 71 ms
71,288 KB |
testcase_10 | AC | 72 ms
71,520 KB |
testcase_11 | AC | 72 ms
71,376 KB |
testcase_12 | AC | 70 ms
71,264 KB |
testcase_13 | AC | 71 ms
71,264 KB |
testcase_14 | WA | - |
testcase_15 | AC | 71 ms
71,176 KB |
testcase_16 | TLE | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
ソースコード
n,k = input().split() C = list(map(int,input().split())) n = int(n) def search(x): C2 = C[:] for i in range(x-1): num = int(k[i])-1 C2[num] -= 1 if C2[num] < 0: return False num = int(k[x-1]) for i in range(num,9): if C2[i]: return True return False l = 0 r = n while r > l + 1: m = (r+l)//2 if search(m): l = m else: r = m if l == 0: print(-1) exit() ans = "" for i in range(l-1): ans += k[i] C[int(k[i])-1] -= 1 num = int(k[l-1]) for j in range(num,9): if C[j]: ans += str(j+1) C[j] -= 1 break for i,c in enumerate(C,1): ans += str(i)*c print(ans)