結果

問題 No.625 ソンタクロース
ユーザー 37zigen37zigen
提出日時 2020-04-19 11:17:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 517 ms / 4,000 ms
コード長 937 bytes
コンパイル時間 2,722 ms
コンパイル使用メモリ 84,264 KB
実行使用メモリ 62,880 KB
最終ジャッジ日時 2024-04-15 06:47:23
合計ジャッジ時間 9,264 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 173 ms
55,192 KB
testcase_01 AC 157 ms
54,976 KB
testcase_02 AC 157 ms
54,872 KB
testcase_03 AC 157 ms
54,892 KB
testcase_04 AC 174 ms
55,036 KB
testcase_05 AC 171 ms
54,908 KB
testcase_06 AC 174 ms
54,980 KB
testcase_07 AC 173 ms
55,160 KB
testcase_08 AC 170 ms
55,172 KB
testcase_09 AC 168 ms
55,116 KB
testcase_10 AC 169 ms
55,116 KB
testcase_11 AC 181 ms
55,024 KB
testcase_12 AC 156 ms
55,036 KB
testcase_13 AC 171 ms
55,016 KB
testcase_14 AC 176 ms
55,136 KB
testcase_15 AC 276 ms
60,364 KB
testcase_16 AC 249 ms
57,912 KB
testcase_17 AC 383 ms
60,716 KB
testcase_18 AC 517 ms
62,024 KB
testcase_19 AC 303 ms
60,824 KB
testcase_20 AC 308 ms
60,796 KB
testcase_21 AC 274 ms
59,768 KB
testcase_22 AC 460 ms
62,880 KB
testcase_23 AC 263 ms
59,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		int[][] a=new int[2][N];
		a[0][0]=M;
		for (int i=1;i<N;++i) {
			Arrays.fill(a[i%2], 0);
			int[][] x=new int[i][2];
			for (int j=0;j<i;++j) {
				x[j][0]=a[(i-1)%2][j];
				x[j][1]=j;
			}
			Arrays.sort(x, Comparator.comparing((int[] v)->v[0]).thenComparing(v->v[1]));
			int need=0;
			for (int j=0;j<(i+1)/2;++j) {
				need+=x[j][0]+1;
				a[i%2][x[j][1]]=x[j][0]+1;
			}
			if (need<=M) {
				a[i%2][i]=M-need;
			} else {
				a[i%2]=Arrays.copyOf(a[(i-1)%2], N);
				a[i%2][i]=-1;
			}
		}
		for (int i=0;i<N;++i) {
			System.out.print(a[(N-1)%2][N-1-i]+(i==N-1?"\n":" "));
		}
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}
0