結果
| 問題 |
No.1630 Sorting Integers (Greater than K)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-08 15:30:59 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 893 bytes |
| コンパイル時間 | 227 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 16,256 KB |
| 最終ジャッジ日時 | 2024-09-19 11:51:25 |
| 合計ジャッジ時間 | 5,412 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 2 WA * 9 TLE * 1 -- * 10 |
ソースコード
n, k = input().split()
n = int(n)
c = list(map(int, input().split()))
if n < len(k): exit(print(-1))
if n > len(k):
ans = ""
for i in range(9):
ans += str(i + 1) * c[i]
exit(print(ans))
f1, f2 = False, False
ans = ""
for i in range(n):
if c[int(k[i]) - 1] > 0:
ans += k[i]
c[int(k[i]) - 1] -= 1
else:
f1 = True
if f1 and not f2:
for j in range(9):
if j + 1 > int(k[i]) and c[j] > 0:
ans += str(j + 1)
c[j] -= 1
break
else:
exit(print(-1))
f2 = True
if f1 and f2:
for j in range(9):
ans += str(j + 1) * c[j]
break
if ans == k:
try:
ans = list(ans)
ans[-1], ans[-2] = ans[-2], ans[-1]
ans = "".join(ans)
except:
exit(print(-1))
if ans == k:
exit(print(-1))
print(ans)