Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.196 s | 13 KBi |
#2 |
Correcto
|
0.212 s | 14 KBi |
#3 |
Correcto
|
0.185 s | 13 KBi |
#4 |
Correcto
|
0.177 s | 15 KBi |
#5 |
Correcto
|
0.162 s | 16 KBi |
#6 |
Correcto
|
0.16 s | 14 KBi |
#7 |
Correcto
|
0.165 s | 13 KBi |
#8 |
Correcto
|
0.19 s | 13 KBi |
#9 |
Correcto
|
0.242 s | 14 KBi |
#10 |
Correcto
|
0.175 s | 15 KBi |
#11 |
Correcto
|
0.188 s | 15 KBi |
#12 |
Correcto
|
0.204 s | 14 KBi |
#13 |
Correcto
|
0.177 s | 13 KBi |
#14 |
Correcto
|
0.197 s | 13 KBi |
#15 |
Correcto
|
0.235 s | 14 KBi |
#16 |
Correcto
|
0.188 s | 14 KBi |
#17 |
Correcto
|
0.22 s | 14 KBi |
#18 |
Correcto
|
0.192 s | 16 KBi |
#19 |
Correcto
|
0.224 s | 13 KBi |
#20 |
Correcto
|
0.23 s | 14 KBi |
#21 |
Correcto
|
0.25 s | 14 KBi |
#22 |
Correcto
|
0.185 s | 23 KBi |
#23 |
Correcto
|
0.241 s | 14 KBi |
#24 |
Correcto
|
0.206 s | 14 KBi |
#25 |
Correcto
|
0.163 s | 13 KBi |
#26 |
Correcto
|
0.408 s | 43 KBi |
#27 |
Correcto
|
0.517 s | 43 KBi |
#28 |
Correcto
|
0.375 s | 51 KBi |
#29 |
Correcto
|
0.336 s | 42 KBi |
#30 |
Correcto
|
0.443 s | 43 KBi |
#31 |
Correcto
|
0.423 s | 45 KBi |
#32 |
Correcto
|
0.455 s | 52 KBi |
#33 |
Correcto
|
0.464 s | 43 KBi |
#34 |
Correcto
|
0.39 s | 43 KBi |
import java.util.*; import java.lang.*; import java.io.*; class Main { public static void main(String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); String number = sc.nextLine(); String v[] = number.split(""); ArrayList<Integer> list = new ArrayList<>(); for (int i = 0; i < number.length(); i++) { list.add(Integer.parseInt(v[i])); } // int v[] = {7,9,5,9,9}; System.out.println(sumOne(list)); } public static String sumOne(ArrayList<Integer> list) { for (int i = list.size()-1; i >= 0; i--) { int value = list.get(i); if(value==9 && i>0){ list.set(i, 0); } else{ list.set(i, value+1); return listToString(list); } } return listToString(list); } public static String listToString(ArrayList<Integer> list) { String st = ""; for (int numb : list) { st+=numb; } return st; } }