This page is still under construction.

Parts of this page are still being built. What you see may change.

Dividing the Highway into Repair Segments

Time limit1sMemory limit128 MB

Summary
Choose a start offset s in [1,m] for tiling the number line into length-m segments, minimizing how many segments contain at least one of the given damaged kilometers, and list all optimal s.
Level

Medium7 of 10

Topics
Math, Sorting, Greedy, Implementation
Solved
No attempts yet

Problem

Bajtazar mastered the art of stacking blocks on a rectangular board, and thanks to his exceptional dexterity he was quickly promoted and joined the Ministry of Infrastructure. His job is to optimize the work of construction crews, and right now he is in charge of repairing highway A1.

The kilometers of the highway are numbered 1,2,3,…1, 2, 3, \dots. The highway is split into segments, each mm kilometers long. If the first segment starts at kilometer ss, then the tt-th segment starts at kilometer s+(t−1) ms + (t-1)\,m; that is, the tt-th segment covers kilometers s+(t−1)ms+(t-1)m through s+t m−1s+t\,m-1.

For every kilometer of the highway we know whether it needs repair. A construction crew must be sent to every mm-kilometer segment that contains at least one kilometer needing repair. The goal is to split the highway into segments so that the number of crews sent is as small as possible.

The first segment must start at one of the first mm kilometers, so 1≤s≤m1 \le s \le m. In addition, none of the first mm kilometers of the highway needs repair.

Write a program that:

  • reads the description of the highway damage from standard input,
  • finds a split into segments that minimizes the required number of crews,
  • writes the result to standard output.

Input

The first line contains two integers mm and uu (1≤m,u≤1000001 \le m, u \le 100000): the length of a single segment and the number of kilometers needing repair.

The second line contains uu integers aia_i in increasing order, separated by single spaces (0≤ai≤20000000000 \le a_i \le 2000000000). Each aia_i denotes one kilometer of the highway that needs repair.

Output

In the first line, output the minimum number of construction crews sent.

In the second line, output every position at which the first segment may start, that is, every start kilometer ss that minimizes the number of crews, in increasing order and separated by single spaces.

Examples3

  1. Example 1

    Input
    4 3
    7 14 15
    
    Expected output
    2
    1 2 4
    
  2. Example 2

    Input
    5 2
    6 10
    
    Expected output
    1
    1
    
  3. Example 3

    Input
    6 5
    8 9 20 21 22
    
    Expected output
    2
    1 2 5 6