結果
問題 |
No.115 遠足のおやつ
|
ユーザー |
|
提出日時 | 2016-08-31 10:38:57 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 722 bytes |
コンパイル時間 | 673 ms |
コンパイル使用メモリ | 119,476 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 03:58:58 |
合計ジャッジ時間 | 1,963 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 WA * 10 |
ソースコード
import std.algorithm, std.array, std.container, std.range; import std.string, std.conv; import std.math, std.bigint, std.bitmanip, std.random; import std.stdio, std.typecons; void main() { auto rd = readln.split.map!(to!int); auto n = rd[0], d = rd[1], k = rd[2]; if (d < comSum(k)) { writeln(-1); } else { auto ai = iota(k).map!(to!int).map!("a + 1").array; foreach_reverse (i; 0..k) { if (ai.sum >= d) break; if (ai.sum < d) { auto b = n - k + 1 + i; auto c = d - (comSum(i) + comSum(k - i - 2) + (b + 1) * (k - i - 1)); ai[i] = min(b, c); } } writeln(ai.map!(to!string).join(' ')); } } int comSum(int k) { return k * (k + 1) / 2; }