結果

問題 No.942 プレゼント配り
ユーザー 37zigen37zigen
提出日時 2019-12-08 08:58:27
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,322 bytes
コンパイル時間 2,412 ms
コンパイル使用メモリ 75,728 KB
実行使用メモリ 68,020 KB
最終ジャッジ日時 2023-08-28 14:03:09
合計ジャッジ時間 17,588 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 161 ms
56,696 KB
testcase_01 AC 984 ms
64,060 KB
testcase_02 AC 124 ms
55,840 KB
testcase_03 AC 123 ms
55,768 KB
testcase_04 AC 1,235 ms
67,192 KB
testcase_05 AC 1,029 ms
67,016 KB
testcase_06 AC 973 ms
62,376 KB
testcase_07 AC 158 ms
56,748 KB
testcase_08 AC 1,030 ms
63,668 KB
testcase_09 AC 1,147 ms
67,136 KB
testcase_10 AC 125 ms
56,012 KB
testcase_11 AC 124 ms
55,988 KB
testcase_12 AC 124 ms
55,780 KB
testcase_13 AC 127 ms
55,816 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 160 ms
57,068 KB
testcase_19 AC 125 ms
55,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.math.*;
import java.io.*;

class Main
{
	public static void main(String[] args)
	{
		new Main().run();
	}
	
	void run(){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();//N個のプレゼント
		int K=sc.nextInt();//K人の子供
		// N%K=0
		if((long)N*(N+1)/2%K!=0){//必ず満たす
			System.out.println("No");
			return;
		}
		int q=N/K;
		if(N==K&&N>1){
			System.out.println("No");
		}if(K==1){
			System.out.println("Yes");
			for(int i=0;i<N;++i){
				System.out.print((i+1)+(i==N-1 ? "\n" : " "));
			}
		}else if(q%2==0){
			System.out.println("Yes");
			for(int i=0;i<K;++i){
				for(int j=0;j<q/2;++j){
					System.out.print((1+j)+(q/2*i));
					System.out.print(" ");
					System.out.print((N-j)-(q/2*i)+(j==(q/2-1)?"\n":" "));
				}
			}
		}else if(K%2==1){
			System.out.println("Yes");
			for(int i=0;i<K;++i){
				long sum=3*(3*K+1)/2;
				long res=sum-(3*K-i)-(2*i%K+1);
				System.out.print((3*K-i)+" "+(2*i%K+1)+" "+res);
				for(int j=0;j<(q-3)/2;++j){
					System.out.print(" ");
					System.out.print((1+j+3*K)+(q/2*i));
					System.out.print(" ");
					System.out.print((N-j)-(q/2*i)+(j==((q-3)/2-1)?"\n":""));
				}
			}
		}else{
			System.out.println("No");
		}
	}
	
	void tr(Object...objects){
		System.out.println(Arrays.deepToString(objects));
	}
}
0