Submission #891696


Source Code Expand

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ilyakor
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            String s = in.nextToken();
            int n = in.nextInt();
            StringBuilder res = new StringBuilder();
            for (int i = 0; i < s.length(); ++i) {
                char c = s.charAt(i);
                int need = (int) ('z' - c) + 1;
                if (need <= n) {
                    c = 'a';
                    n -= need;
                }
                res.append(c);
            }
            s = res.toString();
            res = new StringBuilder();
            for (int i = s.length() - 1; i >= 0; --i) {
                char c = s.charAt(i);
                int need = (int) ('z' - c);
                if (need > n) need = n;
                c += need;
                res.append(c);
                n -= need;
            }
            out.printLine(res.reverse().toString());
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buffer = new byte[10000];
        private int cur;
        private int count;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public static boolean isSpace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int read() {
            if (count == -1) {
                throw new InputMismatchException();
            }
            try {
                if (cur >= count) {
                    cur = 0;
                    count = stream.read(buffer);
                    if (count <= 0)
                        return -1;
                }
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            return buffer[cur++];
        }

        public int readSkipSpace() {
            int c;
            do {
                c = read();
            } while (isSpace(c));
            return c;
        }

        public String nextToken() {
            int c = readSkipSpace();
            StringBuilder sb = new StringBuilder();
            while (!isSpace(c)) {
                sb.append((char) c);
                c = read();
            }
            return sb.toString();
        }

        public int nextInt() {
            int sgn = 1;
            int c = readSkipSpace();
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res = res * 10 + c - '0';
                c = read();
            } while (!isSpace(c));
            res *= sgn;
            return res;
        }

    }
}

Submission Info

Submission Time
Task C - Next Letter
User ilyakor
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 4558 Byte
Status WA
Exec Time 146 ms
Memory 11532 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 7
WA × 20
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 97 ms 8276 KB
0_01.txt AC 96 ms 8400 KB
0_02.txt AC 98 ms 8276 KB
1_00.txt AC 98 ms 8272 KB
1_01.txt AC 98 ms 8272 KB
1_02.txt AC 100 ms 8400 KB
1_03.txt AC 99 ms 8272 KB
1_04.txt WA 97 ms 8276 KB
1_05.txt WA 99 ms 8272 KB
1_06.txt WA 144 ms 11476 KB
1_07.txt WA 145 ms 11528 KB
1_08.txt WA 145 ms 11400 KB
1_09.txt WA 143 ms 11404 KB
1_10.txt WA 146 ms 11404 KB
1_11.txt WA 145 ms 11400 KB
1_12.txt WA 144 ms 11404 KB
1_13.txt WA 144 ms 11476 KB
1_14.txt WA 144 ms 11528 KB
1_15.txt WA 146 ms 11476 KB
1_16.txt WA 141 ms 11532 KB
1_17.txt WA 146 ms 11400 KB
1_18.txt WA 144 ms 11400 KB
1_19.txt WA 144 ms 11476 KB
1_20.txt WA 137 ms 11472 KB
1_21.txt WA 145 ms 11532 KB
1_22.txt WA 144 ms 11476 KB
1_23.txt WA 145 ms 11528 KB