Language: Java


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

public class NewFukushimaken {

	/*** ??°??????????????° */
	private static final int GROUP_NUM = 100;

	private static BufferedReader br;
	private static int placeNum;
	private static int[] arriveTime, customerNum, mealTime, waitTime;

	/*** ??? */
	private static String[] places;
	private static int finalPlace;

	/*** ????????? */
	static {
		br = new BufferedReader(new InputStreamReader(System.in));

		placeNum = 17;
		arriveTime = new int[GROUP_NUM];
		customerNum = new int[GROUP_NUM];
		mealTime = new int[GROUP_NUM];
		waitTime = new int[GROUP_NUM];
		places = new String[placeNum];

	}

	/**
	 * ?????????????????????
	 *
	 * @param args
	 *            ??????????????°
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		String line;
		List<Integer> inputList = new ArrayList<Integer>();

		// ??\???
		while ((line = br.readLine()) != null && !line.isEmpty()) {
			inputList.add(Integer.parseInt(line));
		}

		exe(inputList);

		// ??????
		for (int input : inputList) {
			System.out.println(waitTime[input]);
		}

	}

	private static void exe(List<Integer> inputList) {
		// ?????????
		for (int i = 0; i < GROUP_NUM; i++) {
			arriveTime[i] = 5 * i;
			customerNum[i] = i % 5 == 1 ? 5 : 2;
			mealTime[i] = placeNum * (i % 2) + 3 * (i % 3) + 19;
		}

		int key;

		// ????????¢?????????
		List<Integer> waitList = new ArrayList<Integer>();

		// ??\?????¢?????????
		List<Integer> removeList = new ArrayList<Integer>();

		// ??°??????????????¨?????????????????????????????????????????????
		for (int currentTime = 0; currentTime <= 5 * 100; currentTime++) {

			outStore(currentTime);

			// ?????????????????°????????????
			if ((key = search(arriveTime, currentTime)) != -1) {
				if (waitList.isEmpty()) {
					if (isEmpty(key)) {
						set(Integer.toString(key));
					} else {
						waitList.add(key);
					}
				} else {
					waitList.add(key);
				}
			}

			if (!waitList.isEmpty()) {
				// ???????????¢???????????´???
				int i = 0;
				boolean flg = true;

				for (int wait : waitList) {
					if (isEmpty(wait) && flg) {
						set(Integer.toString(wait));
						waitTime[wait] = currentTime - arriveTime[wait];
						removeList.add(i);
						flg = true;
					} else {
						flg = false;
					}
					i++;
				}
			}

			if (!removeList.isEmpty()) {
				Collections.reverse(removeList);
				for (int remove : removeList) {
					// ??\???????????¢???????????¢???????????????????????????
					waitList.remove(remove);
				}
				removeList = new ArrayList<Integer>();
			}
		}
	}

	private static int search(int[] targets, int currentTime) {
		int i = 0;
		for (int target : targets) {
			if (target == currentTime) {
				return i;
			}
			i++;
		}
		return -1;
	}

	/**
	 * ??????????????£?????°?????????????????????????????????
	 *
	 */
	private static void outStore(int currentTime) {
		int i = 0;
		for (String place : places) {
			if (place == null) {
				i++;
				continue;
			}
			if (mealTime[Integer.parseInt(place)] <= currentTime
					- arriveTime[Integer.parseInt(place)]) {
				places[i] = null;
			}
			i++;
		}

	}

	/**
	 * ??°?????????????????§???????¨??????????
	 *
	 * @param groupNum
	 *            ??°???????????????
	 */
	private static void set(String groupNum) {

		for (int i = finalPlace - 1, count = 0; count < customerNum[Integer
				.parseInt(groupNum)]; i--, count++) {
			places[i] = groupNum;
		}
	}

	/**
	 * ?????°?????°?????????????????°?????§?????????????????????????????????
	 *
	 * @param groupNum
	 *            ??°?????????????????°
	 * @return true : ??§?????? false : ??§?????????
	 */
	private static boolean isEmpty(int groupNum) {

		// ????????°
		int emptyPlaceNum = 0;

		for (int i = 0; i < placeNum; i++) {
			if (emptyPlaceNum == customerNum[groupNum]) {
				finalPlace = i;
				return true;
			}
			if (places[i] == null) {
				emptyPlaceNum++;
			} else {
				emptyPlaceNum = 0;
			}
		}
		return false;
	}
}

Compiler output:
Main.java:9: error: class NewFukushimaken is public, should be declared in a file named NewFukushimaken.java
public class NewFukushimaken {
       ^
1 error