Problem statement is here: http://acm.timus.ru/problem.aspx?space=1&num=2012
public void solve(int testNumber, InputReader in, OutputWriter out) { // given. int totalProblems = 12; int maxHrs = 5; int f = in.nextInt(); int remainingProblems = totalProblems - f; int timeReqd = remainingProblems * 45; if (timeReqd <= 60 * (maxHrs - 1)) { out.println("YES"); } else { out.println("NO"); } }