結果
問題 |
No.115 遠足のおやつ
|
ユーザー |
![]() |
提出日時 | 2017-01-20 22:54:05 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 689 bytes |
コンパイル時間 | 4,189 ms |
コンパイル使用メモリ | 77,948 KB |
実行使用メモリ | 43,364 KB |
最終ジャッジ日時 | 2024-12-23 02:55:54 |
合計ジャッジ時間 | 11,509 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 4 WA * 36 |
ソースコード
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++) { System.out.println(Arrays.toString(r).replaceAll("[^0-9,]", "").replaceAll(",", " ")); 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); } } }