結果
問題 | No.115 遠足のおやつ |
ユーザー | しらゆき |
提出日時 | 2015-12-27 13:43:52 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 26 ms / 5,000 ms |
コード長 | 870 bytes |
コンパイル時間 | 969 ms |
コンパイル使用メモリ | 108,692 KB |
実行使用メモリ | 18,688 KB |
最終ジャッジ日時 | 2025-01-03 01:09:15 |
合計ジャッジ時間 | 3,198 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; class Program { static void Main() { var s = Console.ReadLine().Split(); int n = int.Parse(s[0]); int d = int.Parse(s[1]); int k = int.Parse(s[2]); if (k > n) { Console.WriteLine(-1); return; } int min = k * (1 + k) / 2; int max = k * (2 * n - k + 1) / 2; if (d > max || d < min) { Console.WriteLine(-1); return; } for (int i = 1; i <= n; i++) { if (k == 1 && i == d) { Console.Write(i); break; } if (d - i <= (k - 1) * (2 * n - k + 2) / 2) { Console.Write("{0} ", i); k--; d -= i; } } Console.WriteLine(); } }