結果

問題 No.115 遠足のおやつ
ユーザー tsunabittsunabit
提出日時 2020-03-01 16:29:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 643 bytes
コンパイル時間 2,773 ms
コンパイル使用メモリ 78,408 KB
実行使用メモリ 56,592 KB
最終ジャッジ日時 2023-08-31 00:57:25
合計ジャッジ時間 9,082 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
56,032 KB
testcase_01 AC 113 ms
55,948 KB
testcase_02 AC 127 ms
56,328 KB
testcase_03 AC 103 ms
55,864 KB
testcase_04 AC 116 ms
56,180 KB
testcase_05 AC 122 ms
55,920 KB
testcase_06 AC 104 ms
55,560 KB
testcase_07 AC 117 ms
55,584 KB
testcase_08 AC 103 ms
56,288 KB
testcase_09 AC 98 ms
56,232 KB
testcase_10 AC 101 ms
56,148 KB
testcase_11 AC 102 ms
55,860 KB
testcase_12 AC 105 ms
56,592 KB
testcase_13 AC 108 ms
55,840 KB
testcase_14 AC 115 ms
56,404 KB
testcase_15 AC 118 ms
55,884 KB
testcase_16 AC 116 ms
56,248 KB
testcase_17 AC 121 ms
55,972 KB
testcase_18 AC 102 ms
55,556 KB
testcase_19 AC 119 ms
53,996 KB
testcase_20 AC 114 ms
56,388 KB
testcase_21 AC 120 ms
55,876 KB
testcase_22 AC 117 ms
56,120 KB
testcase_23 AC 103 ms
56,500 KB
testcase_24 AC 114 ms
56,232 KB
testcase_25 AC 115 ms
56,476 KB
testcase_26 AC 115 ms
56,188 KB
testcase_27 AC 116 ms
55,888 KB
testcase_28 AC 119 ms
55,992 KB
testcase_29 AC 124 ms
55,904 KB
testcase_30 AC 117 ms
55,828 KB
testcase_31 AC 119 ms
55,908 KB
testcase_32 AC 118 ms
56,076 KB
testcase_33 AC 119 ms
56,404 KB
testcase_34 AC 116 ms
56,320 KB
testcase_35 AC 122 ms
56,188 KB
testcase_36 AC 116 ms
56,064 KB
testcase_37 AC 120 ms
56,212 KB
testcase_38 AC 118 ms
56,304 KB
testcase_39 AC 106 ms
55,836 KB
testcase_40 AC 105 ms
55,944 KB
testcase_41 AC 101 ms
56,048 KB
testcase_42 AC 117 ms
55,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No115 {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt(), d = s.nextInt(), k = s.nextInt(), sum = 0;
		int[] a = new int[k];
		
		for(int i = 0; i < k; i++) {
			a[i] = i + 1;
			sum += i + 1;
		}
		if(sum > d) {
			System.out.println(-1);
			return;
		}
		for(int i = 0; i < k; i++) {
			sum -= a[a.length-1-i];
			a[a.length-1-i]=Math.min(d-sum, n-i); 
			sum += a[a.length-1-i];
		}
		if(sum == d) {
			for(int i = 0; i < k; i++) {
				System.out.print(a[i] + " ");
			}
		}else {
			System.out.print(-1);
		}
 	}
}
0