301931: CF366B. Dima and To-do List
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Dima and To-do List
题目描述
You helped Dima to have a great weekend, but it's time to work. Naturally, Dima, as all other men who have girlfriends, does everything wrong. Inna and Dima are now in one room. Inna tells Dima off for everything he does in her presence. After Inna tells him off for something, she goes to another room, walks there in circles muttering about how useless her sweetheart is. During that time Dima has time to peacefully complete $ k-1 $ tasks. Then Inna returns and tells Dima off for the next task he does in her presence and goes to another room again. It continues until Dima is through with his tasks. Overall, Dima has $ n $ tasks to do, each task has a unique number from $ 1 $ to $ n $ . Dima loves order, so he does tasks consecutively, starting from some task. For example, if Dima has $ 6 $ tasks to do in total, then, if he starts from the $ 5 $ -th task, the order is like that: first Dima does the $ 5 $ -th task, then the $ 6 $ -th one, then the $ 1 $ -st one, then the $ 2 $ -nd one, then the $ 3 $ -rd one, then the $ 4 $ -th one. Inna tells Dima off (only lovingly and appropriately!) so often and systematically that he's very well learned the power with which she tells him off for each task. Help Dima choose the first task so that in total he gets told off with as little power as possible.输入输出格式
输入格式
The first line of the input contains two integers $ n,k (1<=k<=n<=10^{5}) $ . The second line contains $ n $ integers $ a_{1},a_{2},...,a_{n} (1<=a_{i}<=10^{3}) $ , where $ a_{i} $ is the power Inna tells Dima off with if she is present in the room while he is doing the $ i $ -th task. It is guaranteed that $ n $ is divisible by $ k $ .
输出格式
In a single line print the number of the task Dima should start with to get told off with as little power as possible. If there are multiple solutions, print the one with the minimum number of the first task to do.
输入输出样例
输入样例 #1
6 2
3 2 1 6 5 4
输出样例 #1
1
输入样例 #2
10 5
1 3 5 7 9 9 4 1 8 5
输出样例 #2
3