CODE FESTIVAL 2016 qual A

Submission #1220988

Source codeソースコード

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

Task問題 C - 次のアルファベット / Next Letter
User nameユーザ名 kelvinlu
Created time投稿日時
Language言語 Java8 (OpenJDK 1.8.0)
Status状態 WA
Score得点 0
Source lengthソースコード長 734 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - 0_00.txt,0_01.txt,0_02.txt
All 0 / 400 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
0_00.txt AC 102 ms 20436 KB
0_01.txt AC 172 ms 19284 KB
0_02.txt WA
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
1_07.txt AC 411 ms 31996 KB
1_08.txt WA
1_09.txt WA
1_10.txt WA
1_11.txt WA
1_12.txt WA
1_13.txt WA
1_14.txt WA
1_15.txt WA
1_16.txt WA
1_17.txt WA
1_18.txt WA
1_19.txt WA
1_20.txt WA
1_21.txt WA
1_22.txt WA
1_23.txt WA