結果
| 問題 |
No.115 遠足のおやつ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-01-30 13:53:02 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 716 bytes |
| コンパイル時間 | 641 ms |
| コンパイル使用メモリ | 102,416 KB |
| 実行使用メモリ | 6,940 KB |
| 最終ジャッジ日時 | 2024-06-12 06:42:13 |
| 合計ジャッジ時間 | 1,635 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 WA * 2 |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd = readln.split.to!(int[]), n = rd[0], d = rd[1], k = rd[2];
auto comSum(int i, int j) {
return i > j ? 0 : (j * (j + 1) - (i - 1) * i) / 2;
}
auto calc(int a, int b) {
return comSum(1, a) + comSum(b, n);
}
auto a = k, b = n + 1, c = -1;
if (comSum(1, k) > d || comSum(n - k + 1, n) < d) {
writeln(-1);
} else {
while (calc(a, b) < d) {
if (calc(a - 1, b - 1) < d) {
--a;
--b;
} else {
c = a + d - calc(a, b);
--a;
break;
}
}
auto r = iota(1, a+1).array ~ c ~ iota(b, n+1).array;
writeln(r.to!(string[]).join(" "));
}
}