Submission #1220962
Source Code Expand
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); String string = cin.next(); int K = cin.nextInt(); //贪心算法的最佳体现 int i; for (i=0;i<string.length()-1;i++){ //最后一个字符要单独处理 char c = string.charAt(i); if (c == 'a' || K < 'z' - c +1) { System.out.println('a'); continue; } System.out.print('a'); K -= 'z' - c + 1; } K %= 26; char c = string.charAt(i); if (K >= 'z' - c + 1) { System.out.print((char)('a' + (K - 'z' + c -1 ) % 26)); } else { System.out.print( (char)(c + K)); } } }
Submission Info
Submission Time | |
---|---|
Task | C - Next Letter |
User | kelvinlu |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 678 Byte |
Status | WA |
Exec Time | 622 ms |
Memory | 37680 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | WA | 103 ms | 22228 KB |
0_01.txt | AC | 94 ms | 21204 KB |
0_02.txt | WA | 91 ms | 19156 KB |
1_00.txt | AC | 91 ms | 21332 KB |
1_01.txt | AC | 90 ms | 21844 KB |
1_02.txt | AC | 91 ms | 16980 KB |
1_03.txt | AC | 89 ms | 19924 KB |
1_04.txt | AC | 91 ms | 21716 KB |
1_05.txt | AC | 90 ms | 18644 KB |
1_06.txt | WA | 620 ms | 36216 KB |
1_07.txt | AC | 412 ms | 33532 KB |
1_08.txt | WA | 560 ms | 33296 KB |
1_09.txt | WA | 580 ms | 37568 KB |
1_10.txt | WA | 622 ms | 37680 KB |
1_11.txt | WA | 532 ms | 32816 KB |
1_12.txt | WA | 621 ms | 36592 KB |
1_13.txt | WA | 591 ms | 35560 KB |
1_14.txt | WA | 455 ms | 33072 KB |
1_15.txt | WA | 447 ms | 34304 KB |
1_16.txt | WA | 419 ms | 31684 KB |
1_17.txt | WA | 445 ms | 30252 KB |
1_18.txt | WA | 448 ms | 31644 KB |
1_19.txt | WA | 439 ms | 33140 KB |
1_20.txt | WA | 426 ms | 31332 KB |
1_21.txt | WA | 426 ms | 32340 KB |
1_22.txt | WA | 398 ms | 29984 KB |
1_23.txt | WA | 417 ms | 30288 KB |