codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

899C.md (1406B)


      1 Source: https://codeforces.com/problemset/problem/899/C
      2 
      3 C. Dividing the numbers
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Petya has *n* integers: 1, 2, 3, ..., *n*. He wants to split these integers in two non-empty groups in such a way that the absolute difference of sums of integers in each group is as small as possible.
     22 
     23 Help Petya to split the integers. Each of *n* integers should be exactly in one group.
     24 
     25 Input
     26 
     27 The first line contains a single integer *n* (2 ≤ *n* ≤ 60 000) — the number of integers Petya has.
     28 
     29 Output
     30 
     31 Print the smallest possible absolute difference in the first line.
     32 
     33 In the second line print the size of the first group, followed by the integers in that group. You can print these integers in arbitrary order. If there are multiple answers, print any of them.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 4
     41 ```
     42 
     43 Output
     44 
     45 ```
     46 0  
     47 2 1 4
     48 ```
     49 
     50 Input
     51 
     52 ```
     53 2
     54 ```
     55 
     56 Output
     57 
     58 ```
     59 1  
     60 1 1
     61 ```
     62 
     63 Note
     64 
     65 In the first example you have to put integers 1 and 4 in the first group, and 2 and 3 in the second. This way the sum in each group is 5, and the absolute difference is 0.
     66 
     67 In the second example there are only two integers, and since both groups should be non-empty, you have to put one integer in the first group and one in the second. This way the absolute difference of sums of integers in each group is 1.