- Joined
- Aug 30, 2023
- Messages
- 4
- Reaction score
- 0
Here is the task:
Analyzing weekends and holidays around New Year's and May 1st in Russia, the president of Flatlandia has concluded that the rest of its citizens can be drastically optimized. The main goal is to ensure that citizens do not have to work more than 6 consecutive days in a calendar year. The president has instructed the Ministry of Labor to develop a schedule for transferring weekends (Saturdays and Sundays) so that citizens can have as many consecutive rest days as possible.
It is important to note that if a Flatlandian public holiday falls on a weekend (Saturday or Sunday), that holiday automatically moves to the first working day after the holiday. However, according to the president's decree, any weekend, whether it coincides with a public holiday or not, can be moved to any working day. Public holidays, however, are never moved.
Write a program that will help the Ministry of Labor create the required schedule for transferring weekends in the upcoming year. Public holidays and weekends from the previous and following year should not be considered. The objective is to maximize the number of consecutive rest days in one year.
Input Format:
The first line of input contains two numbers - the year number (Y) (2012≤Y≤2050) and the day of the week for January 1st of that year (W) (1≤W≤7, from Monday to Sunday). In this range of years, leap years are divisible by 4.
The second line contains the number of annual public holidays (N) in Flatlandia. Each of the following N lines contains the date of the next holiday in the format DD.MM. The holiday dates are listed in chronological order, and all dates are valid and correct for the given year.
Output Format:
Output a single number - the maximum possible number of consecutive days off for the residents of Flatlandia in the specified year if the weekends are moved so that the number of consecutive working days in this year does not exceed 6.
Example:
Input:
2012 7
1
01.01
Output:
63
My try:
But uhhh, it doesn't complete the first test, help plzz
Yah its about russia, so sorry..
Analyzing weekends and holidays around New Year's and May 1st in Russia, the president of Flatlandia has concluded that the rest of its citizens can be drastically optimized. The main goal is to ensure that citizens do not have to work more than 6 consecutive days in a calendar year. The president has instructed the Ministry of Labor to develop a schedule for transferring weekends (Saturdays and Sundays) so that citizens can have as many consecutive rest days as possible.
It is important to note that if a Flatlandian public holiday falls on a weekend (Saturday or Sunday), that holiday automatically moves to the first working day after the holiday. However, according to the president's decree, any weekend, whether it coincides with a public holiday or not, can be moved to any working day. Public holidays, however, are never moved.
Write a program that will help the Ministry of Labor create the required schedule for transferring weekends in the upcoming year. Public holidays and weekends from the previous and following year should not be considered. The objective is to maximize the number of consecutive rest days in one year.
Input Format:
The first line of input contains two numbers - the year number (Y) (2012≤Y≤2050) and the day of the week for January 1st of that year (W) (1≤W≤7, from Monday to Sunday). In this range of years, leap years are divisible by 4.
The second line contains the number of annual public holidays (N) in Flatlandia. Each of the following N lines contains the date of the next holiday in the format DD.MM. The holiday dates are listed in chronological order, and all dates are valid and correct for the given year.
Output Format:
Output a single number - the maximum possible number of consecutive days off for the residents of Flatlandia in the specified year if the weekends are moved so that the number of consecutive working days in this year does not exceed 6.
Example:
Input:
2012 7
1
01.01
Output:
63
My try:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
Code:
|
Yah its about russia, so sorry..