Submission #615935


Source Code Expand

// package atcoder.dwango2016.qual;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

/**
 * Created by hama_du on 2016/01/23.
 */
public class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt()-1;
        int[] a = new int[n];
        for (int i = 0; i < n ; i++) {
            a[i] = in.nextInt();
        }

        int[] ans = new int[n+1];
        ans[0] = a[0];
        for (int i = 0 ; i < n-1 ; i++) {
            ans[i+1] = Math.min(a[i], a[i+1]);
        }
        ans[n] = a[n-1];


        StringBuilder line = new StringBuilder();
        for (int i = 0 ; i < ans.length ; i++) {
            line.append(' ').append(ans[i]);
        }
        out.println(line.substring(1));
        out.flush();
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

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

        private int next() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public char nextChar() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            if ('a' <= c && c <= 'z') {
                return (char) c;
            }
            if ('A' <= c && c <= 'Z') {
                return (char) c;
            }
            throw new InputMismatchException();
        }

        public String nextToken() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

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

        public long nextLong() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c-'0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

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

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

    static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }
}

Submission Info

Submission Time
Task B - 積み鉛筆
User hamadu
Language Java (OpenJDK 1.7.0)
Score 80
Code Size 3999 Byte
Status AC
Exec Time 631 ms
Memory 33372 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 80 / 80
Status
AC × 3
AC × 15
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
All subtask0_0.txt, subtask0_1.txt, subtask0_10.txt, subtask0_11.txt, subtask0_12.txt, subtask0_13.txt, subtask0_14.txt, subtask0_2.txt, subtask0_3.txt, subtask0_4.txt, subtask0_5.txt, subtask0_6.txt, subtask0_7.txt, subtask0_8.txt, subtask0_9.txt
Case Name Status Exec Time Memory
sample1.txt AC 397 ms 22312 KB
sample2.txt AC 338 ms 22404 KB
sample3.txt AC 332 ms 22416 KB
subtask0_0.txt AC 470 ms 32752 KB
subtask0_1.txt AC 472 ms 29340 KB
subtask0_10.txt AC 458 ms 28808 KB
subtask0_11.txt AC 472 ms 31376 KB
subtask0_12.txt AC 631 ms 32636 KB
subtask0_13.txt AC 484 ms 29396 KB
subtask0_14.txt AC 496 ms 32896 KB
subtask0_2.txt AC 470 ms 28736 KB
subtask0_3.txt AC 475 ms 33372 KB
subtask0_4.txt AC 460 ms 28804 KB
subtask0_5.txt AC 462 ms 29344 KB
subtask0_6.txt AC 540 ms 32644 KB
subtask0_7.txt AC 466 ms 28836 KB
subtask0_8.txt AC 473 ms 31356 KB
subtask0_9.txt AC 482 ms 32792 KB