0% found this document useful (0 votes)
16 views7 pages

Sample Qs PC

sample

Uploaded by

abdulsami.kh001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views7 pages

Sample Qs PC

sample

Uploaded by

abdulsami.kh001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Disclaimer: The difficulty of actual questions in the competition may slightly differ

from the sample questions. However, the format and number of questions per
round will be identical.

Sample Question 1:

Li has planned a bike tour through the mountains of Switzerland. His tour consists of N
checkpoints, numbered from 1 to N in the order he will visit them. The i-th checkpoint
has a height of Hi.

A checkpoint is a peak if:


● It is not the 1st checkpoint or the N-th checkpoint, and
● The height of the checkpoint is strictly greater than the checkpoint immediately
before it and the checkpoint immediately after it.

Please help Li find out the number of peaks.

Input

The first line of the input gives the number of test cases, T. T test cases follow. Each
test case begins with a line containing the integer N. The second line contains N
integers. The i-th integer is Hi.

Output

For each test case, output one line containing Case #x: y, where x is the test case
number (starting from 1) and y is the number of peaks in Li's bike tour.

Limits

1 ≤ T ≤ 100.

1 ≤ Hi ≤ 100

Sample Input:

4
3
10 20 14
4
7 7 7 7
5
10 90 20 90 10
3
10 3 10
Sample Output:

Case #1: 1
Case #2: 0
Case #3: 2
Case #4: 0

Sample Question 2:

Avery has an array of N positive integers. The i-th integer of the array is Ai.

A contiguous subarray is an m-countdown if it is of length m and contains the integers


m, m-1, m-2, ..., 2, 1 in that order. For example, [3, 2, 1] is a 3-countdown.

Can you help Avery count the number of K-countdowns in her array?

Input

The first line of the input gives the number of test cases, T. T test cases follow. Each
test case begins with a line containing the integers N and K. The second line contains N
integers. The i-th integer is Ai.

Output

For each test case, output one line containing Case #x: y, where x is the test case
number (starting from 1) and y is the number of K-countdowns in her array.

Limits

1 ≤ T ≤ 100.

2 ≤ K ≤ N.

1 ≤ Ai ≤ 2 × 105, for all i.

Sample Input:
3
12 3
1 2 3 7 9 3 2 1 8 3 2 1
4 2
101 100 99 98
9 6
100 7 6 5 4 3 2 1 100

Sample Output:

Case #1: 2
Case #2: 0
Case #3: 1

Sample Question 3:

Isyana is given the number of visitors at her local theme park on N consecutive days.
The number of visitors on the i-th day is Vi. A day is record breaking if it satisfies both of
the following conditions:
● The number of visitors on the day is strictly larger than the number of visitors on
each of the previous days.
● Either it is the last day, or the number of visitors on the day is strictly larger than
the number of visitors on the following day.
Note that the very first day could be a record breaking day!

Please help Isyana find out the number of record breaking days.

Input

The first line of the input gives the number of test cases, T. T test cases follow. Each
test case begins with a line containing the integer N. The second line contains N
integers. The i-th integer is Vi.

Output

For each test case, output one line containing Case #x: y, where x is the test case
number (starting from 1) and y is the number of record breaking days.

Limits

1 ≤ T ≤ 100.
0 ≤ Vi ≤ 2 × 105.

Sample Input:

4
8
1 2 0 7 2 0 2 0
6
4 8 15 16 23 42
9
3 1 4 1 5 9 2 6 5
6
9 9 9 9 9 9

Sample Output:

Case #1: 2
Case #2: 1
Case #3: 3
Case #4: 0

Sample Question 4:

You are in charge of deploying robots to harvest Kickium from a nearby asteroid. Robots
are not designed to work as a team, so only one robot can harvest at any point of time.
A single robot can be deployed for up to K units of time in a row before it returns for
calibration, regardless of how much time it spends on harvesting during that period.
Harvesting can only be done during specific time intervals. These time intervals do not
overlap. Given K and the time intervals in which harvesting is allowed, what is the
minimum number of robot deployments required to harvest at all possible times?

Input

The first line of the input gives the number of test cases, T. T test cases follow.
The first line of each test case gives two space separated integers N and K: the number
of time intervals in which harvesting is allowed, and the maximum duration a robot can
be deployed for before returning for calibration.
The next N lines contain a pair of space separated integers Si and Ei: the start time and
the end time of the i-th interval respectively. Please note that intervals don't include the
time unit starting at the moment Ei, so for example an interval with (Si = 2; Ei = 5) has
duration of 3 time units.

Output

For each test case, output one line containing Case #x: y, where x is the test case
number (starting from 1) and y is the number of times robot deployment is needed so
that for each interval there is one robot harvesting at that time.

Limits

1 ≤ T ≤ 100.

All Si are distinct.

For any two intervals (Si,Ei) and (Sj,Ej) with Si < Sj, Ei < Sj

Sample Input:
2
3 5
1 5
10 11
8 9
3 2
1 2
3 5
13 14

Sample Output:
Case #1: 2
Case #2: 3

Sample Question 5:

You have just heard about a wonderful festival that will last for D days, numbered from 1 to D.
There will be N attractions at the festival. The i-th attraction has a happiness rating of h_i and
will be available from day s_i until day e_i, inclusive.
You plan to choose one of the days to attend the festival. On that day, you will choose up to K
attractions to ride. Your total happiness will be the sum of happiness ratings of the attractions
you chose to ride.

What is the maximum total happiness you could achieve?

Input

The first line of the input gives the number of test cases, T. T test cases follow.

The first line of each test case contains the three integers: D, N and K. The next N lines describe
the attractions. The i-th line contains h_i, s_i and e_i.

Output

For each test case, output one line containing Case #x: y, where x is the test case number
(starting from 1) and y is the maximum total happiness you could achieve.

Limits

1≤ T ≤ 100
1≤K≤N
1 ≤ si ≤ ei ≤ D , for all i
1 ≤ hi ≤ 3 × 10^5, for all i.

Sample Input:
2
10 4 2
800 2 8
1500 6 9
200 4 7
400 3 5
5 3 3
400 1 3
500 5 5
300 2 3

Sample Output:

Case #1: 2300


Case #2: 700

You might also like