結果

問題 No.942 プレゼント配り
ユーザー titiatitia
提出日時 2019-12-05 02:09:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 713 bytes
コンパイル時間 419 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 34,432 KB
最終ジャッジ日時 2024-05-08 20:51:39
合計ジャッジ時間 3,876 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,752 KB
testcase_01 AC 194 ms
21,760 KB
testcase_02 AC 29 ms
10,752 KB
testcase_03 AC 30 ms
10,752 KB
testcase_04 AC 193 ms
18,560 KB
testcase_05 AC 203 ms
21,760 KB
testcase_06 RE -
testcase_07 AC 28 ms
10,752 KB
testcase_08 AC 157 ms
16,640 KB
testcase_09 AC 169 ms
17,536 KB
testcase_10 AC 29 ms
10,880 KB
testcase_11 AC 29 ms
10,752 KB
testcase_12 AC 29 ms
10,752 KB
testcase_13 AC 28 ms
10,624 KB
testcase_14 AC 166 ms
18,312 KB
testcase_15 AC 121 ms
15,232 KB
testcase_16 AC 137 ms
16,000 KB
testcase_17 AC 133 ms
15,872 KB
testcase_18 AC 28 ms
10,752 KB
testcase_19 AC 28 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

if N*(N+1)//2%K!=0:
    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