結果
| 問題 |
No.115 遠足のおやつ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-23 21:15:02 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 717 bytes |
| コンパイル時間 | 73 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-07-05 18:54:07 |
| 合計ジャッジ時間 | 2,172 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 WA * 1 |
ソースコード
N,D,K = [int(i) for i in input().split()]
okashi = [i+1 for i in range(N)]
# okashi[idx:]において、k個でd円ちょうどになる買い方があるか
def check(d, idx, k):
target = okashi[idx:]
# 金額が届かないか、個数が足りない場合は-1
return sum(target[:k]) <= d and d <= sum(target[-k:])
if N < K:
print(-1)
elif not check(D, 0, K):
print(-1)
else:
buy = []
for i in okashi:
if not check(D - (sum(buy) + i), i, K - (len(buy) + 1)):
continue
buy.append(i)
if len(buy) == K - 1:
last_okashi = D - sum(buy)
buy.append(last_okashi)
print(" ".join([str(i) for i in buy]))
break