結果

問題 No.115 遠足のおやつ
ユーザー fal_rndfal_rnd
提出日時 2017-01-20 22:54:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 109 ms / 5,000 ms
コード長 599 bytes
コンパイル時間 2,756 ms
コンパイル使用メモリ 73,160 KB
実行使用メモリ 56,468 KB
最終ジャッジ日時 2023-08-31 00:43:06
合計ジャッジ時間 8,588 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
55,460 KB
testcase_01 AC 99 ms
56,008 KB
testcase_02 AC 103 ms
55,876 KB
testcase_03 AC 100 ms
55,868 KB
testcase_04 AC 102 ms
56,132 KB
testcase_05 AC 102 ms
55,576 KB
testcase_06 AC 100 ms
55,464 KB
testcase_07 AC 106 ms
56,108 KB
testcase_08 AC 103 ms
55,456 KB
testcase_09 AC 98 ms
55,736 KB
testcase_10 AC 100 ms
55,844 KB
testcase_11 AC 102 ms
55,748 KB
testcase_12 AC 97 ms
55,912 KB
testcase_13 AC 105 ms
55,768 KB
testcase_14 AC 103 ms
55,852 KB
testcase_15 AC 106 ms
55,896 KB
testcase_16 AC 103 ms
56,176 KB
testcase_17 AC 106 ms
56,468 KB
testcase_18 AC 101 ms
55,684 KB
testcase_19 AC 108 ms
54,020 KB
testcase_20 AC 102 ms
55,672 KB
testcase_21 AC 97 ms
55,404 KB
testcase_22 AC 101 ms
55,460 KB
testcase_23 AC 101 ms
56,012 KB
testcase_24 AC 106 ms
55,884 KB
testcase_25 AC 106 ms
55,896 KB
testcase_26 AC 106 ms
55,672 KB
testcase_27 AC 101 ms
55,932 KB
testcase_28 AC 107 ms
55,608 KB
testcase_29 AC 103 ms
55,912 KB
testcase_30 AC 102 ms
55,876 KB
testcase_31 AC 104 ms
55,988 KB
testcase_32 AC 107 ms
56,172 KB
testcase_33 AC 105 ms
55,968 KB
testcase_34 AC 104 ms
55,424 KB
testcase_35 AC 100 ms
55,932 KB
testcase_36 AC 105 ms
55,860 KB
testcase_37 AC 103 ms
55,800 KB
testcase_38 AC 103 ms
55,428 KB
testcase_39 AC 103 ms
55,892 KB
testcase_40 AC 109 ms
56,036 KB
testcase_41 AC 109 ms
56,024 KB
testcase_42 AC 105 ms
54,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package src;

import java.util.*;
public class A{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		int sum=0,n=s.nextInt(),d=s.nextInt(),k=s.nextInt();
		int[] r=new int[k];
		for(int i=0;i<k;i++) {
			sum+=i+1;
			r[i]=i+1;
		}
		if(sum>d) {
			System.out.println(-1);
			return;
		}
		for(int i=0;i<k;i++) {
			sum-=r[r.length-1-i];
			r[r.length-1-i]=Math.min(d-sum, n-i);
			sum+=Math.min(d-sum, n-i);
		}
		if(sum==d) {
			System.out.println(Arrays.toString(r).replaceAll("[^0-9,]", "").replaceAll(",", " "));
		}else {
			System.out.println(-1);
		}
	}
}
0