結果
| 問題 | 
                            No.115 遠足のおやつ
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2015-02-10 01:09:13 | 
| 言語 | Python2  (2.7.18)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 422 bytes | 
| コンパイル時間 | 71 ms | 
| コンパイル使用メモリ | 7,040 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-06-23 16:54:16 | 
| 合計ジャッジ時間 | 1,510 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 15 WA * 25 | 
ソースコード
N,D,K = map(int,raw_input().split())
s = []
for i in xrange(1,N+1):
    if sum(s)+i == D or sum(s)+i < D and D-(sum(s)+i) > i:
        s.append(i)
while len(s) > K:
    for i in range(1,len(s))[::-1]:
        if s[i]+s[i-1] <= N and s[i]+s[i-1] not in s:
            s = s[:i-1]+[s[i-1]+s[i]]+s[i+1:]
            s = sorted(s)
            break
    else:
        print -1
        break
else:
    print " ".join(map(str,s))