-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec8a384
commit c4e9255
Showing
7 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import sys | ||
|
||
|
||
def remove(_str, index): | ||
if index == len(_str) - 1: | ||
return _str[:-1] | ||
elif index == 0: | ||
return _str[1:] | ||
return _str[:index] + _str[index + 1 :] | ||
|
||
|
||
for line in sys.stdin: | ||
n, d = map(int, line.split()) | ||
|
||
if not n and not d: | ||
break | ||
|
||
prize = input() | ||
|
||
while d: | ||
possibilities = [remove(prize, i) for i, _ in enumerate(prize)] | ||
possibilities.sort(key=int) | ||
prize = possibilities[-1] | ||
|
||
d -= 1 | ||
|
||
print(prize) |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
30 10 | ||
145276763522376489625376239619 | ||
10 3 | ||
9821122098 | ||
8 4 | ||
95111451 | ||
40 20 | ||
9387678903215673421345672345643212364555 | ||
15 13 | ||
982311121123976 | ||
5 2 | ||
10021 | ||
10 3 | ||
1000010001 | ||
0 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
77676489625376239619 | ||
9822298 | ||
9551 | ||
99772345643212364555 | ||
99 | ||
121 | ||
1010001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
https://www.beecrowd.com.br/judge/en/problems/view/1084 | ||
|
||
# Erasing and Winning | ||
|
||
Juliano is a fan of the TV show Erasing and Winning, where participants are | ||
selected in a draw and receive money for taking part in the show. | ||
|
||
In the show, the presenter writes a number of N digits on a board. Then the | ||
participant must erase exactly D digits from the number on the board; the number | ||
formed by the remaining digits is the value of the money prize for the | ||
participant. | ||
|
||
Juliano was finally selected to take part in the show, and asked you to write a | ||
program that, give the number the presenter wrote on the board, and the number | ||
of digits Juliano must erase, determines the highest value of the prize he can | ||
win. | ||
|
||
## Input | ||
|
||
The input contains several test cases. The first line of a test case contains | ||
two integers $N$ and $D (1 \leq D \lt N \leq 10^5)$ indicating respectively the number of | ||
digits of the number the presenter wrote in the board and the number of digits | ||
that must be erased. The next line contains the number the presenter wrote; the | ||
number does not start with a zero. | ||
|
||
The end of input is indicated by a line containing only two zeros, separated by | ||
a space. | ||
## Output | ||
|
||
For each test case in the input your program must produce one single line in the | ||
output, containing the highest prize Juliano can win. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
paradigms |