codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

435B.md (917B)


      1 Source: https://codeforces.com/problemset/problem/435/B
      2 
      3 B. Pasha Maximizes
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 Pasha has a positive integer *a* without leading zeroes. Today he decided that the number is too small and he should make it larger. Unfortunately, the only operation Pasha can do is to swap two adjacent decimal digits of the integer.
     22 
     23 Help Pasha count the maximum number he can get if he has the time to make at most *k* swaps.
     24 
     25 Input
     26 
     27 The single line contains two integers *a* and *k* (1 ≤ *a* ≤ 1018; 0 ≤ *k* ≤ 100).
     28 
     29 Output
     30 
     31 Print the maximum number that Pasha can get if he makes at most *k* swaps.
     32 
     33 Examples
     34 
     35 Input
     36 
     37 ```
     38 1990 1
     39 ```
     40 
     41 Output
     42 
     43 ```
     44 9190
     45 ```
     46 
     47 Input
     48 
     49 ```
     50 300 0
     51 ```
     52 
     53 Output
     54 
     55 ```
     56 300
     57 ```
     58 
     59 Input
     60 
     61 ```
     62 1034 2
     63 ```
     64 
     65 Output
     66 
     67 ```
     68 3104
     69 ```
     70 
     71 Input
     72 
     73 ```
     74 9090000078001234 6
     75 ```
     76 
     77 Output
     78 
     79 ```
     80 9907000008001234
     81 ```