Submission #1711421
Source Code Expand
import java.io.*; import java.util.*; public class Main { InputStream is; PrintWriter out; String INPUT = ""; int MOD = 1000000007; int INF = 10000000; void solve() { char[] c = ns().toCharArray(); int K = ni(); int[] a = new int[c.length]; for(int i = 0; i < c.length; i++){ a[i] = c[i] - 'a'; } for(int i = 0; i < c.length; i++){ if(i == c.length-1){ if(K > 0){ a[i] += K; } a[i] %= 26; break; } int tmp = 26 - a[i]; if(tmp == 26) continue; else{ if(K >= tmp){ K -= tmp; a[i] = 0; } } } for(int i = 0; i < c.length; i++){ out.print((char)(a[i] + 'a')); } out.println(); } void run() throws Exception { is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes()); out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms"); } public static void main(String[] args) throws Exception { new Main().run(); } private byte[] inbuf = new byte[1024]; private int lenbuf = 0, ptrbuf = 0; private int readByte() { if(lenbuf == -1)throw new InputMismatchException(); if(ptrbuf >= lenbuf){ ptrbuf = 0; try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); } if(lenbuf <= 0)return -1; } return inbuf[ptrbuf++]; } private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; } private double nd() { return Double.parseDouble(ns()); } private char nc() { return (char)skip(); } private String ns() { int b = skip(); StringBuilder sb = new StringBuilder(); while(!(isSpaceChar(b) && b != ' ')){ sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } private char[] ns(int n) { char[] buf = new char[n]; int b = skip(), p = 0; while(p < n && !(isSpaceChar(b))){ buf[p++] = (char)b; b = readByte(); } return n == p ? buf : Arrays.copyOf(buf, p); } private char[][] nm(int n, int m) { char[][] map = new char[n][]; for(int i = 0;i < n;i++)map[i] = ns(m); return map; } private int[] na(int n) { int[] a = new int[n]; for(int i = 0;i < n;i++)a[i] = ni(); return a; } private int ni() { int num = 0, b; boolean minus = false; while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')); if(b == '-'){ minus = true; b = readByte(); } while(true){ if(b >= '0' && b <= '9'){ num = num * 10 + (b - '0'); }else{ return minus ? -num : num; } b = readByte(); } } private long nl() { long num = 0; int b; boolean minus = false; while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')); if(b == '-'){ minus = true; b = readByte(); } while(true){ if(b >= '0' && b <= '9'){ num = num * 10 + (b - '0'); }else{ return minus ? -num : num; } b = readByte(); } } private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); } }
Submission Info
Submission Time | |
---|---|
Task | C - Next Letter |
User | yuya178 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 400 |
Code Size | 4151 Byte |
Status | AC |
Exec Time | 131 ms |
Memory | 24916 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 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 | 68 ms | 19156 KB |
0_01.txt | AC | 69 ms | 20564 KB |
0_02.txt | AC | 69 ms | 23252 KB |
1_00.txt | AC | 70 ms | 20692 KB |
1_01.txt | AC | 69 ms | 18260 KB |
1_02.txt | AC | 68 ms | 21076 KB |
1_03.txt | AC | 67 ms | 19668 KB |
1_04.txt | AC | 68 ms | 19924 KB |
1_05.txt | AC | 69 ms | 18132 KB |
1_06.txt | AC | 107 ms | 21076 KB |
1_07.txt | AC | 111 ms | 23764 KB |
1_08.txt | AC | 127 ms | 21332 KB |
1_09.txt | AC | 111 ms | 23380 KB |
1_10.txt | AC | 110 ms | 24532 KB |
1_11.txt | AC | 123 ms | 22612 KB |
1_12.txt | AC | 131 ms | 21696 KB |
1_13.txt | AC | 119 ms | 24916 KB |
1_14.txt | AC | 108 ms | 22612 KB |
1_15.txt | AC | 108 ms | 23636 KB |
1_16.txt | AC | 124 ms | 22996 KB |
1_17.txt | AC | 110 ms | 24276 KB |
1_18.txt | AC | 120 ms | 22100 KB |
1_19.txt | AC | 108 ms | 21460 KB |
1_20.txt | AC | 119 ms | 24788 KB |
1_21.txt | AC | 108 ms | 21588 KB |
1_22.txt | AC | 95 ms | 24276 KB |
1_23.txt | AC | 115 ms | 24788 KB |