Logo
(追記) (追記ここまで)

33339번 - Group the Numbers 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB23111147.826%

문제

Consider the set of all integers from 1ドル$ to $n$. Split these integers into $k$ equal-sized groups in such a way that the difference between the maximum and minimum sums of integers among all groups is minimized. Formally, if $s_i$ is the sum of integers in $i$-th group, the following value should be minimized:

$$\max\limits_{i=1}^k s_i - \min\limits_{i=1}^k s_i\text{.}$$

입력

The first line contains two integers $n$ and $k$ (1ドル \leq n, k \leq 100,000円$; $n$ is divisible by $k$).

출력

For each group, print a line with all the integers belonging to that group. If there are multiple optimal answers, output any one of them.

제한

예제 입력 1

6 2

예제 출력 1

1 4 5
2 3 6

예제 입력 2

12 3

예제 출력 2

1 7 12 6
10 3 9 4
5 2 8 11

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2023 > Day 2: Nyatl Contest 2023 G번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /