HKJICSample questionsIllustrative · not from the paper
Sample questions
Two theory questions and one practical problem, written in the style of the paper. They show what to expect and how answers are judged. None of them is taken from the competition.
1Theory
The theory phase is 20 multiple-choice questions in 40 minutes, answered on paper with laptops closed. One answer each, and a wrong answer costs nothing.
What does this program output?
x ← 0
for i ← 1 to 5
if i mod 2 = 1
x ← x + i
output xShow the answer
AnswerB
Only the odd values of i pass the test: 1, 3 and 5. Their sum is 9. Option C is the sum of every value from 1 to 5, which is what you get if you miss the condition.
A list of 16 different numbers is sorted from smallest to largest. To find a number, you look at the item in the middle of the part still being searched and discard the half that cannot contain it. In the worst case, how many items must you look at before you have either found the number or can be sure it is not in the list?
Show the answer
AnswerB
Each look rules out the item you looked at and at least half of what is left, so the part still being searched shrinks from 16 items to at most 8, then 4, 2, 1 and finally 0. That is five looks. Option A forgets the last item: with one item left, you still have to look at it.
2Practical
The practical phase is 5 problems in 150 minutes, labelled A to E, written in C++, Python or Java. Your program reads from standard input and writes to standard output, and is run against hidden tests. In the competition each problem is split into subtasks, and every subtask you solve earns its share of the points.
Fastest Lap
You run N laps of the school track and time each one in seconds. Print your fastest lap, and the number of laps you finished in under T seconds.
- Input
The first line contains two integers, N and T.
The second line contains N integers: the lap times, in the order you ran them.
- Output
One line with two integers separated by a space: the fastest lap time, then the number of laps strictly faster than T.
- Limits
1 ≤ N ≤ 100
1 ≤ T ≤ 1000
Every lap time is between 1 and 1000.
Input
5 90
95 88 102 90 79Output
79 2The fastest lap is 79. Two laps, 88 and 79, are under 90. The lap of exactly 90 does not count.
Input
3 60
75 61 60Output
60 0No lap is under 60, so the count is 0.
Show a reference solution
Approach
Read the times once, keeping the smallest seen so far and a count of those below T. The detail that catches people is the comparison: under T means strictly less than T.
Python
n, t = map(int, input().split())
laps = list(map(int, input().split()))
print(min(laps), sum(1 for x in laps if x < t))C++
#include <iostream>
using namespace std;
int main() {
int n, t;
cin >> n >> t;
int best = 1001, under = 0;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
if (x < best) best = x;
if (x < t) under++;
}
cout << best << " " << under << "\n";
}Java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt(), t = in.nextInt();
int best = 1001, under = 0;
for (int i = 0; i < n; i++) {
int x = in.nextInt();
if (x < best) best = x;
if (x < t) under++;
}
System.out.println(best + " " + under);
}
}