Submission #5448296


Source Code Expand

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();
		int k = Integer.parseInt(br.readLine());
		br.close();

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			int a = 26 - (c - 'a');
			if (a == 26) {
				sb.append('a');
			} else if (a <= k) {
				sb.append('a');
				k -= a;
			} else {
				sb.append(c);
			}
		}

		if (k > 0) {
			char c = sb.charAt(sb.length() - 1);
			int a = 26 - (c - 'a');
			k %= 26;
			if (k < a) {
				sb.setCharAt(sb.length() - 1, (char) (c + k));
			} else {
				sb.setCharAt(sb.length() - 1, (char) ('a' + (k - a)));
			}
		}
		System.out.println(sb.toString());
	}
}

Submission Info

Submission Time
Task C - Next Letter
User ks2m
Language Java8 (OpenJDK 1.8.0)
Score 400
Code Size 896 Byte
Status AC
Exec Time 113 ms
Memory 28628 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 27
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 67 ms 19284 KB
0_01.txt AC 67 ms 18644 KB
0_02.txt AC 96 ms 17492 KB
1_00.txt AC 67 ms 18644 KB
1_01.txt AC 68 ms 19668 KB
1_02.txt AC 67 ms 19156 KB
1_03.txt AC 68 ms 20692 KB
1_04.txt AC 67 ms 18644 KB
1_05.txt AC 69 ms 17108 KB
1_06.txt AC 108 ms 23124 KB
1_07.txt AC 100 ms 22868 KB
1_08.txt AC 99 ms 23380 KB
1_09.txt AC 112 ms 23380 KB
1_10.txt AC 107 ms 28628 KB
1_11.txt AC 113 ms 24148 KB
1_12.txt AC 107 ms 20564 KB
1_13.txt AC 107 ms 25300 KB
1_14.txt AC 108 ms 24660 KB
1_15.txt AC 109 ms 24788 KB
1_16.txt AC 107 ms 22100 KB
1_17.txt AC 109 ms 23508 KB
1_18.txt AC 106 ms 22868 KB
1_19.txt AC 109 ms 22868 KB
1_20.txt AC 98 ms 23892 KB
1_21.txt AC 98 ms 21460 KB
1_22.txt AC 108 ms 24660 KB
1_23.txt AC 108 ms 24148 KB