Recently Added TSSOJ Problemshttps://tssoj.ca/2022-05-26T21:04:47+00:00The latest problems added on the Thornhill Secondary School Online Judge websiteAge Demographic2022-05-26T21:04:47+00:002022-05-26T21:04:47+00:00https://tssoj.ca/problem/demographic<p>You have just uploaded your first video as a content creator.</p>
<p>Curious about which audiences you should be targeting, you have gathered data about \(N\:(1 \le N \le 3 \cdot 10^5)\) different viewers. Specifically, you know the ages \(x_i\:(1 \le x_i \le 10^9)\) of every single person that has watched your video.</p>
<p>Given \(Q\:(1 \le Q \le 3 \cdot 10^5)\) different queries, how many people between the ages of \(a\) and \(b\) inclusive \((1 \le a, b \le 10^9)\) have watched your video...WC '17 Contest 3 J3 - Uncrackable2022-05-20T17:21:16+00:002022-05-20T17:21:16+00:00https://tssoj.ca/problem/wc17c3j3<h4>Woburn Challenge 2017-18 Round 3 - Junior Division</h4>
<p>You'd like to register an account on an extremely entertaining website. You've already selected a username, but it seems that the requirements for choosing a password are quite strict, in order to completely protect your account from being hacked into. The password must be a string between \(8\) and \(12\) characters long (inclusive), such that every character is either a lowercase letter (<code>a</code> … <code>z</code>), uppercase ...COCI '18 Contest 3 #1 Magnus2022-05-20T16:35:05+00:002022-05-20T16:35:05+00:00https://tssoj.ca/problem/coci18c3p1<p>Magnus lost a game of chess to Kile so he found comfort in competitive programming. Very soon, he heard of the iconic COCI competition and decided to try his luck there.</p>
<p>He wrote a mail to Kile: "<em>Dear Kile, please, prepare me for COCI. Magnus</em>".</p>
<p>Kile replied: "<em>You want to participate in COCI? All right, here's your warm-up task. A series of four consecutive letters of some word that make up the subword <code>HONI</code> (Croatian acronym for COCI) is called the HONI-...Three Cups2022-05-18T02:25:46+00:002022-05-18T02:25:46+00:00https://tssoj.ca/problem/coci06c5p1<h4>COCI '06 Contest 5 #1 Trik</h4>
<p>Jealous of Mirko's position as head of the village, Borko stormed into his tent and tried to demonstrate Mirko's incompetence for leadership with a trick.</p>
<p>Borko puts three opaque cups onto the table next to each other (opening facing down) and a small ball under the leftmost cup. He then swaps two cups in one of three possible ways a number of times. Mirko has to tell which cup the ball ends up under.</p>
<p><img src="https://static.dmoj.ca/texoid/0e...CCC '18 J1 - Telemarketer or not?2022-05-11T01:41:11+00:002022-05-11T01:41:11+00:00https://tssoj.ca/problem/ccc18j1<h4>Canadian Computing Competition: 2018 Stage 1, Junior #1</h4>
<p>Here at the Concerned Citizens of Commerce (CCC), we have noted that telemarketers like to use seven-digit phone numbers where the last four digits have three properties. Looking just at the last four digits, these properties are:</p>
<ul>
<li>the first of these four digits is an <strong>8</strong> or <strong>9</strong>;</li>
<li>the last digit is an <strong>8</strong> or <strong>9</strong>;</li>
<li>the second and third digits ...CCC '19 J1 - Winning Score2022-05-10T20:35:05+00:002022-05-10T20:35:05+00:00https://tssoj.ca/problem/ccc19j1<h4>Problem Description</h4>
<p>You record all of the scoring activity at a basketball game. Points are scored by a 3-point shot, a
2-point field goal, or a 1-point free throw.
You know the number of each of these types of scoring for the two teams: the Apples and the
Bananas. Your job is to determine which team won, or if the game ended in a tie.</p>
<h4>Input Specification</h4>
<p>The first three lines of input describe the scoring of the Apples, and the next three lines of input
describe the ...Problem J1: Who is in the middle?2022-05-10T17:00:57+00:002022-05-10T17:00:57+00:00https://tssoj.ca/problem/ccc07j1<h4>Problem Description</h4>
<p>In the story Goldilocks and the Three Bears, each bear had a bowl of porridge to eat while sitting
at his/her favourite chair. What the story didn’t tell us is that Goldilocks moved the bowls around
on the table, so the bowls were not at the right seats anymore. The bowls can be sorted by weight
with the lightest bowl being the Baby Bear’s bowl, the medium bowl being the Mama Bear’s bowl
and the heaviest bowl being the Papa Bear’s bowl. Write a program that reads ...CCC '15 J2 - Happy or Sad2022-05-10T02:14:05+00:002022-05-10T02:14:05+00:00https://tssoj.ca/problem/ccc15j2<h4>Problem Description</h4>
<p>We often include emoticons in our text messages to indicate how we are feeling. The three consecutive characters <code>:-)</code> indicate a happy face and the three consecutive characters <code>:-(</code> indicate a sad face. Write a program to determine the overall mood of a message.</p>
<h4>Input Specification</h4>
<p>There will be one line of input that contains between <strong>1</strong> and <strong><em>255</em></strong> characters.
Output Specification
The o...CCC '15 J1 - Special Day2022-05-09T23:24:13+00:002022-05-09T23:24:13+00:00https://tssoj.ca/problem/ccc15j1<h4>Canadian Computing Competition: 2015 Stage 1, Junior #1</h4>
<p>February 18 is a special date for the CCC this year.</p>
<p>Write a program that asks the user for a numerical month and numerical day of the month and then determines whether that date occurs before, after, or on February 18.</p>
<ul>
<li>If the date occurs before February 18, output the word <code>Before</code>. </li>
<li>If the date occurs after February 18, output the word <code>After</code>. </li>
<li>If the date is Februar...CCC '06 J1 - Canadian Calorie Counting2022-05-06T18:48:17+00:002022-05-06T18:48:17+00:00https://tssoj.ca/problem/ccc06j1<h4>Problem Description</h4>
<p>At Chip's Fast Food emporium there is a very simple menu. Each food item is selected by entering a digit choice.</p>
<table class="table" style="width: 500px;">
<tbody><tr>
<td style="text-align: left;">
Here are the three burger choices:<br>
1 – Cheeseburger (461 Calories)<br>
2 – Fish Burger (431 Calories)<br>
3 – Veggie Burger (420 Calories)<br>
4 – no burger</td>
<td style="text-align: left;">
Here are the three drink choices:<br>
1 – Soft Drink (130 Calories)...Victor's Various Adventures - Victor Writes A Math Contest2022-03-20T21:14:15+00:002022-03-20T21:14:15+00:00https://tssoj.ca/problem/victor4<p><strong><em>This is problem 4 of the <code>Victor's Various Adventures</code> problem set.</em></strong></p>
<p>Victor is writing a math contest, and easily solves all of the problems. However, he wants to test you with a very easy problem that was on the contest. To make it even easier for you, he has decided that you can write a program to solve the problem. The problem is as follows:</p>
<blockquote><p>We define an <em>expression</em> as something that can be evaluated to a real number, or...Victor's Various Adventures - Victor Climbs Mt. Everest2022-03-20T16:50:09+00:002022-03-20T16:50:09+00:00https://tssoj.ca/problem/victor1<p><strong><em>This is problem 1 of the <code>Victor's Various Adventures</code> problem set.</em></strong></p>
<p>Victor is climbing Mt. Everest, but on the way up, he meets a magical genie. The genie will not let him pass unless he answers the following question:</p>
<blockquote><p>Given a string \(S\), containing a mathematical expression with <code>+</code> and <code>-</code> operations, evaluate the result to one decimal place. Note, the string will always end with a <code>=</code>, and the...CCC '02 J2 - AmeriCanadian2022-03-19T16:43:36+00:002022-03-19T16:43:36+00:00https://tssoj.ca/problem/americanadian<h4>Problem Description</h4>
<p>Americans spell differently from Canadians. Americans write <code>neighbor</code> and <code>color</code> while Canadians write <code>neighbour</code> and <code>colour</code>. Write a program to help Americans translate to Canadian.</p>
<p>Your program should interact with the user in the following way. The user should type a word (not to exceed 64 letters) and if the word appears to use American spelling, the program should echo the Canadian spelling for the same ...CCC '22 J3 - Harp Tuning2022-03-13T22:56:02+00:002022-03-13T22:56:02+00:00https://tssoj.ca/problem/harptuning<h4>Problem Description</h4>
<p>The CCC harp is a stringed instrument with strings labelled A, B, . . . , T. Like other instruments, it can be out of tune.</p>
<p>A musically inclined computer science student has written a clever computer program to help tune the harp. The program analyzes the sounds produced by the harp and provides instructions to fix each string that is out of tune. Each instruction includes a group of strings, whether they should be tightened or loosened, and by how many tur...CCC '22 J2 - Fergusonball Ratings2022-03-12T04:44:48+00:002022-03-12T04:44:48+00:00https://tssoj.ca/problem/fergusonballratings<p>Fergusonball players are given a star rating based on the number of points that they score
and the number of fouls that they commit. Specifically, they are awarded \(5\) stars for each
point scored, and \(3\) stars are taken away for each foul committed. For every player, the
number of points that they score is greater than the number of fouls that they commit.
Your job is to determine how many players on a team have a star rating greater than \(40\).
You also need to determine if the team is...CCC '22 J1 - Cupcake Party2022-03-12T04:15:46+00:002022-03-12T04:15:46+00:00https://tssoj.ca/problem/cupcakeparty<p>A regular box of cupcakes holds 8 cupcakes, while a small box holds 3 cupcakes. There are
28 students in a class and a total of at least 28 cupcakes. Your job is to determine how many cupcakes will be left over if each student gets one cupcake.</p>
<p><img src="https://static.dmoj.ca/media/martor/d29b12a0-fbb0-4b72-bccb-627515757f1a.png" alt="A regular box of cupcakes and a small box of cupcakes"></p>
<h4>Input Specification</h4>
<p>The input consists of two lines.</p>
<ul>
<li>The first line...CCC '22 S2 - Good Groups2022-03-12T03:24:53+00:002022-03-12T03:24:53+00:00https://tssoj.ca/problem/goodgroups<p>Canadian Computing Competition: 2022 Stage 1, Junior #4, Senior #2
A class has been divided into groups of three. This division into groups might violate two types of constraints: some students must work together in the same group, and some students must work in separate groups.</p>
<p>Your job is to determine how many of the constraints are violated.</p>
<p>Input Specification
The first line will contain an integer with . The next lines will each consist of two different names, separated b...TSSPC Contest 2 P3 - Joe's Dominoes2021-10-05T21:13:48+00:002021-10-05T21:13:48+00:00https://tssoj.ca/problem/tsspc2p3<p>Joe is making a domino trail. After placing all the pieces, he decides to change the trail so the heights of the dominoes (strictly) increase then (strictly) decrease. Find the minimum number of dominoes he must remove. (A strictly increasing sequence satisfies \(a_i < a_{i+1}\) and a strictly decreasing sequence satisfies \(a_i > a_{i+1}\)).</p>
<h4>Input Specification</h4>
<p>The first line of input contains a single integer \(N\) \((3 \leq N \leq 500\,000)\).</p>
<p>The next line con...TSSPC Contest 2 P2 - Grammar checker2021-10-03T04:13:53+00:002021-10-03T04:13:53+00:00https://tssoj.ca/problem/tsspc2p2<p>Joe is writing a formal essay for his English course. He wants you to write a program to calculate his final score. His teacher deducts 2 marks for an incorrect capitalization (first letter is capital, capital for letter after period, no capital otherwise) and incorrect punctuation (periods and commas must be followed by a space (except last), must end in a period). His teacher deducts contractions and personal pronouns by 1 mark and slang language is an instant 10 mark deduction.</p>
<h4>Inp...TSSPC Contest 2 P1 - Joe's Birds2021-10-01T04:17:01+00:002021-10-01T04:17:01+00:00https://tssoj.ca/problem/tsspc2p1<p>Joe has exactly \(N\) birds, who he loves very much. Joe loves his birds so much that he decided to enter them into a bird flying competition. However, to register a bird into the competition, it must have a minimum flying height of \(K\). Each bird \(i\) has a maximum flying height of \(H_i\). Help Joe determine how many birds he is able to enter into the bird flying competition.</p>
<h4>Input Specification</h4>
<p>The first line of input contains two integers \(N\) and \(K\) \((1 \le N \le ...Victor's Various Adventures - Victor Counts Marbles II2021-05-06T19:09:28+00:002021-05-06T19:09:28+00:00https://tssoj.ca/problem/victor3<p><strong><em>This is problem 3 of the <code>Victor's Various Adventures</code> problem set.</em></strong></p>
<p>Victor is becoming a king! But wait, before he becomes a king, he must prove himself worthy! Traditionally, to become a king, one must complete the following task:</p>
<blockquote><p>You are given a line of \(N\) marbles, each marble is either black or white. You are then given \(M\) requirements, where the \(i^\text{th}\) requirement states that between marbles \(L_i\) and \(R_i\) ...Radar2021-05-06T18:51:20+00:002021-05-06T18:51:20+00:00https://tssoj.ca/problem/radar<p>You just got a multi-million dollar contract to operate radar infrastructure.</p>
<p>Each radar outputs \(N\) data points it has collected while rotating in a circle. Each data point \(i\) consists of a value \(a_i\). You are to find the longest consecutive sequence of data points that has a value <em>strictly</em> less than \(K\).</p>
<p><strong>Notice points \(a_1\) and \(a_N\) are considered consecutive since it wraps around!</strong></p>
<h4>Input Specification</h4>
<p>The first line cont...Yesn't2021-05-01T19:50:50+00:002021-05-01T19:50:50+00:00https://tssoj.ca/problem/yesnt<p>While surfing the internet, you have discovered a brand new word!</p>
<p>The word <code>yesnt</code> has the <a href="https://www.urbandictionary.com/define.php?term=Yesn%27t" rel="nofollow">meaning</a> of <code>no</code>. Similarly, <code>nont</code> has the meaning of <code>yes</code>. When the suffix <code>nt</code> is added multiple times, the meaning of the words alternate between <code>yes</code> and <code>no</code>. For example, the word <code>yesntnt</code> has the meaning of yes.</p>...TSSPC Contest 2 P4 - Cheapskate2021-03-26T19:14:39+00:002021-03-26T19:14:39+00:00https://tssoj.ca/problem/tsspc2p4<p>Joe loves bubble tea. However, he hates spending money, so he always buys the cheapest product. His favourite chain, Bubble tea and me, has a set of \(N\) bubble tea items with a corresponding price and product number from \([1, N]\). They will also occasionally replace items. Their menu displays a set of items with consecutive product numbers from \(l\) to \(r\) inclusive. Given the original prices, product replacements and items displayed, find the cheapest bubble tea item available wheneve...TSSPC Contest 1 P5 - Trick or Trail2021-03-06T19:36:37+00:002021-03-06T19:36:37+00:00https://tssoj.ca/problem/tsspc20c1p5<p>It's Halloween and [user:Henry_Zhang] loves candy, but is too scared to go trick or treating (he's very afraid). He lives in a terrifying grid neighbourhood of dimension \(n\) x \(m\). [user:sankeeth_ganeswaran] lives at \((0,0)\) and he wants to deliver candy to [user:Henry_Zhang] who lives at \((n,m)\). [user:sankeeth_ganeswaran] rides his old haunted broomstick but accidentally trips and squishes it, breaking it under all his weight! His broken broom can only fly him up or right on the gri...