Language: Java

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main{

    // ??£?????????????????????????????????
    private int time = 0;

    // ?????????????????????????????§????????°???????????°
    private int groupCount = 0;

    public static void main(String[] args) throws Exception {
	new Fukushimaken().execute();
    }

    private void execute() throws Exception {

	// ?¨??????\????????????????????????
	List<Integer> targetGroups = readInitialData();

	// ?????°(17???)
	EatingVisitor[] seats = new EatingVisitor[17];

	// ?????£?????????????????????
	List<WaitingVisitor> waitingGroups = new ArrayList<WaitingVisitor>();

	// ?????°?????????????????????????¨??????????
	List<Integer> waitTimes = new ArrayList<Integer>();

	// ??????????????????????????????????????????????????°??????????????????
	int maxGroupNum = searchMaxGroupNum(targetGroups);

	// ?????????????????§??°??????????????????????????£????????????
	while (groupCount <= maxGroupNum) {

	    // ???????????´??°
	    waitingGroups.addAll(updateWaitLine());

	    // ??¢?????????
	    leaveSeat(seats);

	    // ????????????
	    waitTimes.addAll(sitDown(seats, waitingGroups));

	    time++;
	}

	// ????????????
	for (int targetGroup : targetGroups) {
	    System.out.println(waitTimes.get(targetGroup));
	}
    }

    /**
     * ??§??????????????????
     * 
     * @param seats
     *            ??????????????§???(17???)
     * @param waitingGroups
     *            ?????§?????£???????????°?????????
     */
    private List<Integer> sitDown(EatingVisitor[] seats, List<WaitingVisitor> waitingGroups) {

	List<Integer> waitTimes = new ArrayList<Integer>();

	int removeCount = 0;
	for (WaitingVisitor waitingPerson : waitingGroups) {

	    int emptySeatCount = 0;
	    boolean isEmpty = false;
	    for (int i = 0; i < seats.length; i++) {

		// ????????°????????\
		if (seats[i] == null) {
		    emptySeatCount++;
		} else {
		    emptySeatCount = 0;
		}

		if (waitingPerson.getNumber() == emptySeatCount) {

		    // ????????§??£?????°???????????°?????´??°
		    groupCount++;
		    removeCount++;
		    isEmpty = true;

		    // ????±???°????????????????????????????¨????
		    waitTimes.add(time - waitingPerson.getStartTime());

		    // ?£???????????????????????¨????
		    int endTime = 17 * (waitingPerson.getGroup() % 2) + 3 * (waitingPerson.getGroup() % 3) + 19;

		    for (int j = 0; j < emptySeatCount; j++) {
			seats[i - j] = new EatingVisitor(waitingPerson.getGroup(), endTime + time);
		    }
		    break;
		}
	    }

	    if (!isEmpty) {
		break;
	    }

	}

	// ?£????????§?????????????????????????
	for (int i = 0; i < removeCount; i++) {
	    waitingGroups.remove(0);
	}

	return waitTimes;
    }

    /**
     * ?£???????????????£???????????¢????????????
     * 
     * @param seats
     *            ??§???
     */
    private void leaveSeat(EatingVisitor[] seats) {
	for (int i = 0; i < seats.length; i++) {
	    if (seats[i] != null && seats[i].getEndTime() == time) {
		seats[i] = null;
	    }
	}
    }

    /**
     * ?????£????????????????????´??°
     * 
     * @return ????????????
     */
    private List<WaitingVisitor> updateWaitLine() {

	List<WaitingVisitor> waitingGroups = new ArrayList<WaitingVisitor>();

	int nowGroup = time / 5;
	// ??°?????????????????£??????????????????
	if (time % 5 == 0) {
	    // ??°?????????????????°?????????
	    int number = 2;
	    if (nowGroup % 5 == 1) {
		number = 5;
	    }

	    // ??????????????????????????????????§?????????????????¨????
	    waitingGroups.add(new WaitingVisitor(nowGroup, number, time));
	}

	return waitingGroups;
    }

    /**
     * ?¨??????\????????????????????????
     * 
     * @return ??????????????°?????????
     */
    private List<Integer> readInitialData() throws Exception {

	BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

	String line = null;
	List<Integer> groups = new ArrayList<Integer>();
	while ((line = reader.readLine()) != null) {
	    groups.add(Integer.parseInt(line));
	}

	return groups;
    }

    /**
     * ???????????????????????§??°??????????????????????´¢
     * 
     * @param targetGroups
     *            ??????????±??????°?????????
     * @return ??°???????????????
     */
    private int searchMaxGroupNum(List<Integer> targetGroups) {
	int maxGroupNum = 0;
	for (int targetGroup : targetGroups) {
	    if (maxGroupNum < targetGroup) {
		maxGroupNum = targetGroup;
	    }
	}
	return maxGroupNum;
    }

}

/**
 * ?????¢??????
 */
abstract class Visitor {

    // ????±???°?????????
    private int group;

    public int getGroup() {
	return group;
    }

    public void setGroup(int group) {
	this.group = group;
    }

}

/**
 * ?????§?????£??????????????¢??????
 */
class WaitingVisitor extends Visitor {

    public WaitingVisitor(int group, int number, int startTime) {
	setGroup(group);
	setNumber(number);
	setStartTime(startTime);
    }

    // ???????§?????????????
    private int startTime;

    // ??°?????????????????°
    private int number;

    public int getStartTime() {
	return startTime;
    }

    public void setStartTime(int startTime) {
	this.startTime = startTime;
    }

    public int getNumber() {
	return number;
    }

    public void setNumber(int number) {
	this.number = number;
    }
}

/**
 * ?£???????????????¢??????
 */
class EatingVisitor extends Visitor {

    public EatingVisitor(int group, int endTime) {
	setGroup(group);
	setEndtTime(endTime);
    }

    // ?£???????????????????
    private int endtTime;

    public int getEndTime() {
	return endtTime;
    }

    public void setEndtTime(int endtTime) {
	this.endtTime = endtTime;
    }

}

Compiler output:
Main.java:15: error: cannot find symbol
	new Fukushimaken().execute();
	    ^
  symbol:   class Fukushimaken
  location: class Main
1 error