Submission #891667
Source Code Expand
import java.io.*; import java.util.*; public class Main { FastScanner in; PrintWriter out; void solve() { char[] s = in.next().toCharArray(); int k = in.nextInt(); for (int i = 0; i < s.length; i++) { int need = 'z' + 1 - s[i]; if (need <= k) { s[i] = 'a'; k -= need; } } int last = s[s.length - 1] - 'a'; last = (last + k) % 26; s[s.length - 1] = (char) ('a' + last); out.println(new String(s)); } void run() { try { in = new FastScanner(new File("object.in")); out = new PrintWriter(new File("object.out")); solve(); out.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } } void runIO() { in = new FastScanner(System.in); out = new PrintWriter(System.out); solve(); out.close(); } class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner(File f) { try { br = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException e) { e.printStackTrace(); } } public FastScanner(InputStream f) { br = new BufferedReader(new InputStreamReader(f)); } String next() { while (st == null || !st.hasMoreTokens()) { String s = null; try { s = br.readLine(); } catch (IOException e) { e.printStackTrace(); } if (s == null) return null; st = new StringTokenizer(s); } return st.nextToken(); } boolean hasMoreTokens() { while (st == null || !st.hasMoreTokens()) { String s = null; try { s = br.readLine(); } catch (IOException e) { e.printStackTrace(); } if (s == null) return false; st = new StringTokenizer(s); } return true; } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } } public static void main(String[] args) { new Thread(null, new Runnable() { public void run() { new Main().runIO(); } }, "1", 1 << 26).start(); } }
Submission Info
Submission Time | |
---|---|
Task | C - Next Letter |
User | qwerty787788 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 2143 Byte |
Status | WA |
Exec Time | 132 ms |
Memory | 11520 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 | 96 ms | 8432 KB |
0_01.txt | AC | 98 ms | 8404 KB |
0_02.txt | AC | 101 ms | 8404 KB |
1_00.txt | AC | 99 ms | 8400 KB |
1_01.txt | AC | 101 ms | 8452 KB |
1_02.txt | AC | 97 ms | 8432 KB |
1_03.txt | AC | 100 ms | 8432 KB |
1_04.txt | AC | 98 ms | 8328 KB |
1_05.txt | AC | 97 ms | 8428 KB |
1_06.txt | AC | 131 ms | 11376 KB |
1_07.txt | AC | 132 ms | 11472 KB |
1_08.txt | WA | 131 ms | 11476 KB |
1_09.txt | WA | 132 ms | 11392 KB |
1_10.txt | WA | 129 ms | 11520 KB |
1_11.txt | WA | 128 ms | 11376 KB |
1_12.txt | WA | 130 ms | 11372 KB |
1_13.txt | WA | 128 ms | 11376 KB |
1_14.txt | WA | 130 ms | 11476 KB |
1_15.txt | WA | 129 ms | 11476 KB |
1_16.txt | AC | 130 ms | 11472 KB |
1_17.txt | AC | 131 ms | 11472 KB |
1_18.txt | AC | 130 ms | 11472 KB |
1_19.txt | AC | 132 ms | 11472 KB |
1_20.txt | AC | 129 ms | 11348 KB |
1_21.txt | AC | 130 ms | 11368 KB |
1_22.txt | AC | 131 ms | 11372 KB |
1_23.txt | AC | 129 ms | 11476 KB |