Logo
(追記) (追記ここまで)

32909번 - Minimization by Swaps 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB219861.538%

문제

Masha is studying large numbers. She has placed $n$ cards in a row. Each card has a digit from 1ドル$ to 9ドル$ written on it. Together, they form an $n$-digit integer $s$.

In one operation, Masha can take two adjacent cards and swap them (she cannot rotate the cards, turning one digit into another). Masha can perform no more than $k$ operations. What is the minimum $n$-digit number that can be obtained as a result?

입력

The first line contains an integer $t$: the number of test cases (1ドル \le t \le 100,000円$). The following lines contain the test cases.

Each test case is given on a line containing two integers $s$ and $k$ separated by a space. The integer $s$ is positive and consists of digits from 1ドル$ to 9ドル$. Additionally, 0ドル \le k \le 10^{18}$.

The total number of digits in all numbers $s$ does not exceed 100ドル,000円$.

출력

For each test case, print a line with the answer: the minimum $n$-digit number that can be obtained from $s$ by swapping two adjacent digits no more than $k$ times.

제한

예제 입력 1

4
321 0
9 1
21241127 10
692 1

예제 출력 1

321
9
11122247
629

힌트

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > ICPC 2024-2025 Northwestern Russia Qualification H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /