SHOW:
|
|
- or go back to the newest paste.
| 1 | import java.util.*; | |
| 2 | ||
| 3 | public class Upr {
| |
| 4 | public static void main(String[] args) {
| |
| 5 | Scanner scan = new Scanner(System.in); | |
| 6 | ||
| 7 | String input = scan.nextLine(); | |
| 8 | ||
| 9 | String[] texts = input.split(">");
| |
| 10 | int strength = 0; | |
| 11 | int strengthLeft = 0; | |
| 12 | ||
| 13 | for (int i = 0; i < texts.length; i++) {
| |
| 14 | if (Character.isDigit(texts[i].charAt(0))) {
| |
| 15 | strength = Character.getNumericValue(texts[i].charAt(0)) + strengthLeft; | |
| 16 | ||
| 17 | if (texts[i].length() >= strength) {
| |
| 18 | texts[i] = texts[i].substring(strength); | |
| 19 | } else {
| |
| 20 | strengthLeft = strength - texts[i].length(); | |
| 21 | texts[i] = ""; | |
| 22 | } | |
| 23 | } | |
| 24 | ||
| 25 | if (i == texts.length - 1) {
| |
| 26 | System.out.print(texts[i]); | |
| 27 | } else {
| |
| 28 | System.out.print(texts[i] + ">"); | |
| 29 | } | |
| 30 | } | |
| 31 | } | |
| 32 | } |