結果
問題 |
No.2027 (1, 2, 3, …, N) 's Subset Sum
|
ユーザー |
|
提出日時 | 2022-12-13 20:08:43 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 426 bytes |
コンパイル時間 | 510 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 103,552 KB |
最終ジャッジ日時 | 2024-11-07 14:18:26 |
合計ジャッジ時間 | 8,270 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 |
other | WA * 25 |
ソースコード
import sys if sys.platform =='ios': import clipboard a=clipboard.get() a = a.split('\n') text = '\n'.join(a) with open('input_file.txt','w') as f: f.write(text) sys.stdin = open('input_file.txt') ans = [] n,s = map(int,input().split()) for i in range(n,0,-1): if s-i >= 0: s -= i ans.append(i) else: continue if s == 0: break print(ans) if s != 0: exit(print(-1)) print(max(ans)) print(*ans[::-1])