Submission #1220949
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 (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 | 664 Byte |
Status | WA |
Exec Time | 436 ms |
Memory | 35596 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 | 92 ms | 19668 KB |
0_01.txt | AC | 90 ms | 18768 KB |
0_02.txt | AC | 90 ms | 21844 KB |
1_00.txt | AC | 90 ms | 19796 KB |
1_01.txt | AC | 92 ms | 21716 KB |
1_02.txt | AC | 91 ms | 21332 KB |
1_03.txt | AC | 92 ms | 17620 KB |
1_04.txt | AC | 92 ms | 18900 KB |
1_05.txt | AC | 90 ms | 18640 KB |
1_06.txt | AC | 436 ms | 35548 KB |
1_07.txt | AC | 425 ms | 35344 KB |
1_08.txt | WA | 420 ms | 35312 KB |
1_09.txt | WA | 412 ms | 33396 KB |
1_10.txt | WA | 429 ms | 33552 KB |
1_11.txt | WA | 401 ms | 31940 KB |
1_12.txt | WA | 411 ms | 33820 KB |
1_13.txt | WA | 402 ms | 35596 KB |
1_14.txt | WA | 414 ms | 33424 KB |
1_15.txt | WA | 405 ms | 31692 KB |
1_16.txt | AC | 431 ms | 33880 KB |
1_17.txt | AC | 411 ms | 31092 KB |
1_18.txt | AC | 430 ms | 31600 KB |
1_19.txt | AC | 418 ms | 35104 KB |
1_20.txt | AC | 408 ms | 35332 KB |
1_21.txt | AC | 433 ms | 33272 KB |
1_22.txt | AC | 422 ms | 32392 KB |
1_23.txt | AC | 421 ms | 31312 KB |