ContestTraining
SRM 827 · 2022-04-04 · by misof
Problem Statement
Ela decided to practice her problem solving skills by solving some number of problems each day. In order to avoid burnout, she alternately has some heavy days on which she solves many problems and then some light days on which she solves fewer problems.
The number of days of each type are given in the
You are given a collection of queries in the
Constraints
- heavyDays will be between 1 and 10^18, inclusive.
- lightDays will be between 1 and 10^18, inclusive.
- heavyProblems and lightProblems will satisfy 1 <= lightProblems < heavyProblems <= 10^18.
- queries will have between 1 and 200 elements, inclusive.
- Each element of queries will be between 1 and 10^18, inclusive.
5
2
5
1
{5, 21, 25, 26, 27, 28, 32, 43, 50}
Returns: {1, 5, 5, 6, 7, 8, 8, 11, 12 }
Ela has alternately 5 heavy days (Monday to Friday) and 2 light days (Saturday, Sunday). On each heavy day she solves 5 problems, on each light day she solves 1 problem. The beginning of her schedule looks as follows: Day 1 (Monday): problems 1-5 Day 2 (Tuesday): problems 6-10 Day 3 (Wednesday): problems 11-15 Day 4 (Thursday): problems 16-20 Day 5 (Friday): problems 21-25 Day 6 (Saturday): problem 26 Day 7 (Sunday): problem 27 Day 8 (Monday): problems 28-32 Day 9 (Tuesday): problems 33-37 Day 10 (Wednesday): problems 38-42 Day 11 (Thursday): problems 43-47 Day 12 (Friday): problems 48-52 Day 13 (Saturday): problem 53 ... Thus: she solves her 5th problem still on day 1, her 21st and 25th problem are both solved on day 5, the 26th problem on day 6, the 27th problem on day 7, problems with numbers 28-32 are solved on day 8 (which is a heavy day again), and so on.
1
1234567890
10
1
{7, 17, 18, 19, 20, 987654321, 987654322, 2345678901, 345678901234}
Returns: {1, 8, 9, 10, 11, 987654312, 987654313, 2345678883, 345678898714 }
On the very first day Ela solves 10 problems. Then she has very many light days and on each of them she only solves a single problem. For all queries except for the last two the corresponding problem is solved before her second heavy day.
1
1
2
1
{987654321987654321, 123456789123456789}
Returns: {658436214658436214, 82304526082304526 }
123456789123456789
123456789123456789
2
1
{987654321987654321, 123456789123456789}
Returns: {617283954617283954, 61728394561728395 }
907654321987654321
907654321987654321
2
1
{987654321987654321, 123456789123456789}
Returns: {493827160993827161, 61728394561728395 }
1
1234567890
10
1
{19, 345678901234, 987654322, 18, 17, 2345678901, 987654321, 20, 20, 20, 7}
Returns: {10, 345678898714, 987654313, 9, 8, 2345678883, 987654312, 11, 11, 11, 1 }
Queries aren't necessarily given in sorted order. Queries aren't necessarily distinct.
Submissions are judged against all 177 archived test cases, of which 6 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class ContestTraining with a public method vector<long long> practice(long long heavyDays, long long lightDays, long long heavyProblems, long long lightProblems, vector<long long> queries) · 177 test cases · 2 s / 256 MB per case