TCCC '24 Feb P3 - Snowy Days

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

Thornhill Computer Club 2024 - February Mock CCC - Problem 3

Joe likes to go sledding. Of course, to go sledding, there must be snow. On any given day, snow will form if the temperature is below 0 degrees Celsius and the humidity is above 70 percent. However, Joe is an elitist sledder and will only go sledding if there is sufficient snow. Specifically, he will only go sledding on a given day if it has been snowing for at least two consecutive days directly before the given day.

Given the temperature and the humidity of N different days. Determine how many good snow days Joe will get to go sledding.

Input Specifications

The first line will contain a single integer N (3 \le N \le 1000), the total number of days.
The next line will contain N space-separated integers t_i (-40 \le t_i \le 40), the temperature of the ith day in degrees Celsius.
The last line will contain N space-separated integers h_i (0 \le h_i \le 100), the percent humidity of the ith day.

Output Specifications

On a single line, output a single integer D, the number of days Joe finds suitable for sledding.

Sample Input 1

6
3 -2 -1 -4 -3 0
80 70 73 75 71 68

Sample Output 1

2

Explanation for Sample Output 1

It will snow on the 3rd, 4th, and 5th day. The first day is too warm for snow to form and the second day is not humid enough. The last day is not cold enough and not humid enough for snow to form. The 5th and 6th day are the only days good enough for Joe. Prior to the 5th day, it was snowing on the 3rd and 4th day. Prior to the 6th day, it was snowing on the 5th and 4th day. Since both these days had at least two days of snow prior to themselves, they satisfy Joe's conditions for a good snow day.

Sample Input 2

4
34 32 29 30
26 40 39 58

Sample Output 2

0

Explanation for Sample Output 2

It is too warm for snow to form, so there are no good days for Joe to go sledding. After all, Joe should not be attempting to sled in the summer.


Comments

There are no comments at the moment.