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