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.

Question 1Easy5 points

What does this program output?

x ← 0
for i ← 1 to 5
    if i mod 2 = 1
        x ← x + i
output x
  1. A6
  2. B9
  3. C15
  4. D5
Show 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.

Question 2Medium10 points

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?

  1. A4
  2. B5
  3. C8
  4. D16
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.

Problem AVery Easy120 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.

Example 1

Input

5 90
95 88 102 90 79

Output

79 2

The fastest lap is 79. Two laps, 88 and 79, are under 90. The lap of exactly 90 does not count.

Example 2

Input

3 60
75 61 60

Output

60 0

No 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);
    }
}

Registration

Not open yet

Registration has not opened yet. It will be free, and open to students at every school in Hong Kong.

Registration opens
To be announced
Competition
Sat 17 Apr 2027