CCCGuide
Warm-ups (J1–J2)

The First 30 Marks

very-frequent

The first two problems of the Junior CCC are usually the easiest 30 marks on the contest. They don't require advanced algorithms. Most of the work is reading the problem carefully and translating it directly into code.

This module goes through the common patterns in J1 and J2 problems, using real CCC problems.

J1 Walkthrough: Concert Tickets2026 · J1 · Original problem · DMOJ

Besa wants to buy tickets for the upcoming Saylor Twift concert.

Given the total number of tickets for the concert and the number of tickets other people have purchased, your job is to determine whether or not Besa can buy her desired number of tickets.

The first line of input contains a positive integer, BB, representing the number of tickets Besa wants to buy. The second line contains a positive integer, TT, representing the total number of tickets for the concert. The third line contains a positive integer, PP, where P≤TP \leq T, representing the number of tickets other people have purchased.

If Besa cannot buy BB tickets, output N. Otherwise, output Y, followed by a single space, followed by the number of tickets that would remain after Besa buys BB tickets.

5
100
70

Output for Sample Input 1

Y 25

Explanation of Output for Sample Input 1

There are a total of 100100 tickets for the concert. Besa wants to buy 55 tickets and other people have purchased 7070 tickets. So, 100−75=25100 - 75 = 25 tickets would remain after Besa buys 55 tickets.

3
200000
199998

Output for Sample Input 2

N

Explanation of Output for Sample Input 2

There are a total of 200 000200\,000 tickets for the concert. Besa wants to buy 33 tickets and other people have purchased 199 998199\,998 tickets. So, Besa cannot buy 33 tickets.

Solution

First, we need to determine how many tickets are still available before Besa makes her purchase.

There are T tickets in total, and P have already been purchased, so:

T−P T - P

tickets remain.

Besa can buy B tickets if there are at least B tickets remaining:

T−P≥B T - P \geq B

If this is true, we subtract B from the remaining tickets and output Y followed by the number of tickets left after her purchase.

Otherwise, we output N.

Implementation

B = int(input())
T = int(input())
P = int(input())

remaining = T - P

if remaining >= B:
    print("Y", remaining - B)
else:
    print("N")

J2 Walkthrough: Olympic Scores2026 · J2 · Original problem · DMOJ

An athlete participating in an Olympic event is scored by a panel of five judges. Each judge gives the athlete an integer score from 00 to 1010 (inclusive).

To ensure that the scoring is fair, one occurrence of the highest score is removed and one occurrence of the lowest score is removed. The athlete's overall score is then determined by summing the three remaining scores and multiplying this total by the event's designated difficulty factor.

Given the scores from the panel of judges and the event's difficulty factor, your job is to determine the athlete's overall score.

The first five lines of input contain the scores from the five judges: S1, S2, S3, S4S_1,\,S_2,\,S_3,\,S_4, and S5S_5. Each score will be an integer between 00 and 1010 (inclusive).

The sixth line of input contains a positive integer, DD, representing the event's difficulty factor.

Output the non-negative integer, TT, which is the athlete's overall score.

7
10
8
0
10
3

Output for Sample Input

75

Explanation of Output for Sample Input

The five scores are 7,10,8,0,107, 10, 8, 0, 10. After removing one occurrence of the highest score and the only occurrence of the lowest score, the three remaining scores are 7,8,107, 8, 10. Therefore, the athlete's overall score is (7+8+10)×3=75(7 + 8 + 10) \times 3 = 75.

Solution

We read the five scores and the difficulty factor D.

The overall score removes one occurrence of the highest score and one occurrence of the lowest score, then adds up the three scores that remain:

(S1+S2+S3+S4+S5)−max⁡−min⁡ (S_1 + S_2 + S_3 + S_4 + S_5) - \max - \min

where max is the highest of the five scores and min is the lowest. Since only one occurrence of each is removed, this works even when judges tie — the sample has two 10s, and only one of them is removed.

Finally, the result is multiplied by the difficulty factor:

((S1+S2+S3+S4+S5)−max⁡−min⁡)×D ((S_1 + S_2 + S_3 + S_4 + S_5) - \max - \min) \times D

Implementation

scores = [int(input()) for _ in range(5)]
D = int(input())

print((sum(scores) - max(scores) - min(scores)) * D)

Takeaways

The main idea in these problems is to keep the solution simple. Read the input, identify what the problem is asking for, and translate those steps into code. If you can do that reliably, you can solve a large part of the Junior CCC without needing complicated algorithms.

The next module works through three more J1 and J2 problems using the same approach.

On this page

Contributors