Problem:
Score: 200 points

Problem Statement

The restaurant AtCoder serves the following five dishes:

ABC Don (rice bowl): takes A minutes to serve.

ARC Curry: takes B minutes to serve.

AGC Pasta: takes C minutes to serve.

APC Ramen: takes D minutes to serve.

ATC Hanbagu (hamburger patty): takes E minutes to serve.

Here, the time to serve a dish is the time between when an order is placed and when the dish is delivered.

This restaurant has the following rules on orders:

An order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).

Only one dish can be ordered at a time.

No new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.

E869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.

Here, he can order the dishes in any order he likes, and he can place an order already at time 0.

Constraints

A, B, C, D and E are integers between 1 and 123 (inclusive).

Input

Input is given from Standard Input in the following format:

A
B
C
D
E

Output

Print the earliest possible time for the last dish to be delivered, as an integer.

Sample Input 1

29
20
7
35
120

Sample Output 1

215

If we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:

Order ABC Don at time 0, which will be delivered at time 29.

Order ARC Curry at time 30, which will be delivered at time 50.

Order AGC Pasta at time 50, which will be delivered at time 57.

Order ATC Hanbagu at time 60, which will be delivered at time 180.

Order APC Ramen at time 180, which will be delivered at time 215.

There is no way to order the dishes in which the last dish will be delivered earlier than this.

Sample Input 2

101
86
119
108
57

Sample Output 2

481

If we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:

Order AGC Pasta at time 0, which will be delivered at time 119.

Order ARC Curry at time 120, which will be delivered at time 206.

Order ATC Hanbagu at time 210, which will be delivered at time 267.

Order APC Ramen at time 270, which will be delivered at time 378.

Order ABC Don at time 380, which will be delivered at time 481.

There is no way to order the dishes in which the last dish will be delivered earlier than this.

Sample Input 3

123
123
123
123
123

Sample Output 3

643

This is the largest valid case.

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Accepted)


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {

    private static FastScanner sc = new FastScanner();
    private static Solution solution = new Solution();

    private static int[][] neg8 = new int[][]{{-1, -1}, {0, -1}, {1, -1}, {-1, 0}, {1, 0}, {-1, 1}, {0, 1}, {1, 1}};
    private static int[][] neg4 = new int[][]{{1, 0}, {0, -1}, {-1, 0}, {0, 1}};
    /*  neg4    neg8
     *    3      678
     *   2*0     4*5
     *    1      123
     */
    public static void main(String[] args) {


        int[] array = sc.arrayInt(5);

        int min = 9;

        int ans = 0;

        boolean flag = false;

        for(int i = 0;i < 5;i++){

            if(array[i] % 10 != 0){
                if(min >= array[i] % 10){
                    min = array[i] % 10;
                    flag = true;
                }
                array[i] = array[i] + (10 - array[i] % 10);
            }
//            System.out.println(array[i]);
            ans += array[i];


        }
        if(flag)ans -= 10-min;

        System.out.println(ans);

    }
}

class Solution {
    public String stringLCS(String s1,String s2){//最長部分文字列そのものを返す
        int l1 = s1.length();//s1の長さ
        int l2 = s2.length();//s2の長さ
        StringBuilder ans = new StringBuilder();
        int last = 0;
        if(l1==0||l2==0){
            return ans.toString();
        }

        int[][] m = new int[l1][l2];
        int maxLen = 0;

        for(int i = 0;i < l1;i++){
            if(s1.charAt(i)==s2.charAt(0)){
                m[i][0] = 1;
                maxLen = 1;
            }else{
                m[i][0] = 0;
            }
        }

        for(int i = 0;i < l2;i++){
            if(s1.charAt(0)==s2.charAt(i)){
                m[0][i] = 1;
                maxLen = 1;
                last = i;
            }else{
                m[0][i] = 0;
            }
        }

        for(int i = 1;i < l1;i ++){
            for(int j = 1;j < l2;j ++){
                if(s1.charAt(i)!=s2.charAt(j)){
                    m[i][j] = 0;
                }else{
                    m[i][j] = m[i-1][j-1] + 1;
                    if(m[i][j] > maxLen){
                        maxLen = m[i][j];
                        last = i;
                    }
                }
            }
        }

        for(int i = last - maxLen +1;i <= last;i++){
            ans.append(String.valueOf(s1.charAt(i)));
        }

        return ans.toString();

    }
    public int countLCS(String s1,String s2){//最長共通部分文字列 文字数を返す
        int l1 = s1.length();//s1の長さ
        int l2 = s2.length();//s2の長さ
        if(l1==0||l2==0){
            return 0;
        }

        int[][] m = new int[l1][l2];
        int maxLen = 0;

        for(int i = 0;i < l1;i++){
            if(s1.charAt(i)==s2.charAt(0)){
                m[i][0] = 1;
                maxLen = 1;
            }else{
                m[i][0] = 0;
            }
        }

        for(int i = 0;i < l2;i++){
            if(s1.charAt(0)==s2.charAt(i)){
                m[0][i] = 1;
                maxLen = 1;
            }else{
                m[0][i] = 0;
            }
        }

        for(int i = 1;i < l1;i ++){
            for(int j = 1;j < l2;j ++){
                if(s1.charAt(i)!=s2.charAt(j)){
                    m[i][j] = 0;
                }else{
                    m[i][j] = m[i-1][j-1] + 1;
                    maxLen = m[i][j] > maxLen?m[i][j]:maxLen;
                }
            }
        }
        return maxLen;


    }

    public List<Integer> prime_factorization(int n){//素数のリストを返す　例：n=12...2,2,3
        final List<Integer> list = new ArrayList<Integer>();
        if(n < 2){
            return list;
        }

        while(n!=1&&n%2==0){
            list.add(2);
            n >>>= 1;
        }

        for(int i = 3;i*i<n;i+=2){
            while(n%i==0){
                list.add(i);
                n/=i;
            }
        }
        if(n!=1){
            list.add(n);
        }
        return list;
    }

    public int count_divisor(int n) {//約数の数を返す
        final List<Integer> list = new ArrayList<Integer>();
        int count = 1;
        int temp;
        if (n < 2) {
            return count;
        }

        temp = 0;
        while (n != 1 && n % 2 == 0) {
            temp++;
            n >>>= 1;
        }
        count *= temp + 1;


        for (int i = 3; i * i < n; i += 2) {
            temp = 0;
            while (n % i == 0) {
                temp++;
                n /= i;
            }
            count *= temp + 1;
        }
        if (n != 1) {
            count*=2;
        }
        return count;
    }
}

class FastScanner extends PrintWriter {
    private final InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    FastScanner() {
        this(System.in);
    }

    FastScanner(InputStream source) {
        super(System.out);
        this.in = source;
    }

    boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    int readByte() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }

    boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    boolean isNewLine(int c) {
        return c == '\n' || c == '\r';
    }

    void skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    void skipNewLine() {
        while (hasNextByte() && isNewLine(buffer[ptr])) ptr++;
    }

    boolean hasNext() {
        skipUnprintable();
        return hasNextByte();
    }

    boolean hasNextLine() {
        skipNewLine();
        return hasNextByte();
    }

    String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    char[] nextCharArray(int len) {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        char[] s = new char[len];
        int i = 0;
        int b = readByte();
        while (isPrintableChar(b)) {
            if (i == len) {
                throw new InputMismatchException();
            }
            s[i++] = (char) b;
            b = readByte();
        }
        return s;
    }

    String nextLine() {
        if (!hasNextLine()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (!isNewLine(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    char nextChar() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        return (char) readByte();
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    int[] arrayInt(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = nextInt();
        return a;
    }

    long[] arrayLong(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) a[i] = nextLong();
        return a;
    }

    double[] arrayDouble(int n) {
        double[] a = new double[n];
        for (int i = 0; i < n; i++) a[i] = nextDouble();
        return a;
    }

    void arrayInt(int[]... a) {
        for (int i = 0; i < a[0].length; i++) for (int j = 0; j < a.length; j++) a[j][i] = nextInt();
    }

    int[][] matrixInt(int n, int m) {
        int[][] a = new int[n][];
        for (int i = 0; i < n; i++) a[i] = arrayInt(m);
        return a;
    }

    char[][] mapChar(int n, int m) {
        char[][] a = new char[n][];
        for (int i = 0; i < n; i++) a[i] = nextCharArray(m);
        return a;
    }

    public void close() {
        super.close();
        try {
            in.close();
        } catch (IOException ignored) {
        }
    }
}