Problem statement is here: http://acm.timus.ru/problem.aspx?space=1&num=2056
The problem statement is not at all clear. Note that if a student has got statisfactory marks then that student will not get any scholarships. Once this is clear, the problem can be solve using simple if-else blocks.
public void solve(int testNumber, InputReader in, OutputWriter out) { int n = in.nextInt(); double sumOfMarks = 0; for (int i = 0; i < n; i++) { double marks = in.nextDouble(); if (marks == 3.0) { out.println("None"); return; } sumOfMarks += marks; } double avgMarks = sumOfMarks / (double) n; if (avgMarks == 5.0) { out.println("Named"); } else if (avgMarks >= 4.5) { out.println("High"); } else { out.println("Common"); } }