結果

問題 No.942 プレゼント配り
ユーザー titiatitia
提出日時 2019-12-05 02:11:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 220 ms / 2,000 ms
コード長 692 bytes
コンパイル時間 223 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 21,888 KB
最終ジャッジ日時 2024-05-08 21:00:48
合計ジャッジ時間 3,731 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,752 KB
testcase_01 AC 220 ms
21,888 KB
testcase_02 AC 33 ms
10,752 KB
testcase_03 AC 31 ms
10,752 KB
testcase_04 AC 209 ms
18,688 KB
testcase_05 AC 216 ms
21,760 KB
testcase_06 AC 31 ms
10,752 KB
testcase_07 AC 31 ms
10,880 KB
testcase_08 AC 162 ms
16,768 KB
testcase_09 AC 179 ms
17,536 KB
testcase_10 AC 31 ms
10,752 KB
testcase_11 AC 32 ms
10,624 KB
testcase_12 AC 30 ms
10,624 KB
testcase_13 AC 33 ms
10,752 KB
testcase_14 AC 179 ms
18,204 KB
testcase_15 AC 126 ms
15,104 KB
testcase_16 AC 148 ms
15,872 KB
testcase_17 AC 144 ms
15,872 KB
testcase_18 AC 32 ms
10,752 KB
testcase_19 AC 32 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())
if N==K==1:
    print("Yes")
    print(1)
    exit()

if N*(N+1)//2%K!=0 or N==K:
    print("No")
else:
    ANS=[[0]*(N//K) for i in range(K)]

    rest=N//K
    col=0

    if rest%2==1:

        start=0

        for i in range(K):
            ANS[i][0]=1+i

        for i in range(K):
            ANS[(i+K//2)%K][1]=K+i+1

        for i in range(K):
            ANS[i][2]=3*(K*3+1)//2-ANS[i][0]-ANS[i][1]

        col+=3

    for i in range(K):
        for j in range(col,rest):
            if j%2==0:
                ANS[i][j]=1+i+j*K
            else:
                ANS[i][j]=K-i+j*K

    print("Yes")
    for ans in ANS:
        print(*ans)
                
0