結果
問題 |
No.15 カタログショッピング
|
ユーザー |
|
提出日時 | 2018-11-04 18:16:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 535 bytes |
コンパイル時間 | 718 ms |
コンパイル使用メモリ | 67,268 KB |
実行使用メモリ | 10,144 KB |
最終ジャッジ日時 | 2024-11-20 20:01:10 |
合計ジャッジ時間 | 28,899 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 TLE * 4 |
ソースコード
#include<iostream> using namespace std; int p[32], sum[32] = {}; int n, s; void dfs(int i, int a, string str){ if(a == s){ cout << str.substr(1) << endl; return; } if(i == n || a + sum[i] < s) return; if(a + p[i] <= s) dfs(i+1, a+p[i], str + " " + to_string(i+1)); if(a + sum[i+1] >= s) dfs(i+1, a, str); } int main(){ cin >> n >> s; for(int i = 0; i < n; i++) cin >> p[i]; for(int i = 30; i >= 0; i--) sum[i] += sum[i+1] + p[i]; dfs(0, 0, ""); return 0; }