Submission #1220988
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') { System.out.println('a'); continue; } if (K < 'z' - c + 1) { System.out.print(c); 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 | 734 Byte |
Status | WA |
Exec Time | 620 ms |
Memory | 38704 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 | AC | 102 ms | 20436 KB |
0_01.txt | AC | 172 ms | 19284 KB |
0_02.txt | WA | 91 ms | 19796 KB |
1_00.txt | AC | 90 ms | 21972 KB |
1_01.txt | AC | 90 ms | 19924 KB |
1_02.txt | AC | 90 ms | 18644 KB |
1_03.txt | AC | 90 ms | 19796 KB |
1_04.txt | AC | 92 ms | 18768 KB |
1_05.txt | AC | 92 ms | 21716 KB |
1_06.txt | WA | 620 ms | 38704 KB |
1_07.txt | AC | 411 ms | 31996 KB |
1_08.txt | WA | 442 ms | 35308 KB |
1_09.txt | WA | 411 ms | 31348 KB |
1_10.txt | WA | 422 ms | 34220 KB |
1_11.txt | WA | 394 ms | 30048 KB |
1_12.txt | WA | 497 ms | 30588 KB |
1_13.txt | WA | 442 ms | 33688 KB |
1_14.txt | WA | 435 ms | 33704 KB |
1_15.txt | WA | 429 ms | 30220 KB |
1_16.txt | WA | 449 ms | 34440 KB |
1_17.txt | WA | 448 ms | 32176 KB |
1_18.txt | WA | 446 ms | 30272 KB |
1_19.txt | WA | 452 ms | 35484 KB |
1_20.txt | WA | 402 ms | 29092 KB |
1_21.txt | WA | 447 ms | 33152 KB |
1_22.txt | WA | 444 ms | 32532 KB |
1_23.txt | WA | 428 ms | 32344 KB |