結果
| 問題 |
No.115 遠足のおやつ
|
| コンテスト | |
| ユーザー |
YamaKasa
|
| 提出日時 | 2018-07-10 16:24:10 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 169 ms / 5,000 ms |
| コード長 | 724 bytes |
| コンパイル時間 | 4,047 ms |
| コンパイル使用メモリ | 77,804 KB |
| 実行使用メモリ | 42,496 KB |
| 最終ジャッジ日時 | 2025-01-03 01:30:32 |
| 合計ジャッジ時間 | 12,582 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
import java.util.Scanner;
public class Maiin {
static int D;
static int N;
static int K;
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
N = scan.nextInt();
D = scan.nextInt();
K = scan.nextInt();
scan.close();
int min = sum(K);
int max = sum(N) - sum(N - K);
int res = D;
int k = 1;
if(min > D || max < D) {
System.out.println(-1);
}else {
for(int i = 1; i <= N; i++) {
int t1 = res - i;
int t2 = sum(N) - sum(N - K + k);
if(t2 >= t1) {
k++;
System.out.print(i + " ");
res -= i;
if(k == K) {
System.out.println(res);
System.exit(0);
}
}
}
}
}
static int sum(int n) {
return n * (n + 1) / 2;
}
}
YamaKasa