Editorial for DMOPC '17 Contest 1 P2 - Sharing Crayons
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
For the first subtask, we can loop through all subarrays and find their sum, and count how many are divisible by
Time Complexity:
For the second subtask, we can iterate through all subarrays and find their sum using a prefix sum array, and count how many are divisible by
Time Complexity:
Let
For the third subtask, notice that the sum of a subarray
Time Complexity:
For the fourth subtask, we can replace the counter array with a map data structure, as an array of size
Time Complexity:
Extra Challenge: Can you solve this problem without using a map data structure?
Comments