結果
| 問題 |
No.15 カタログショッピング
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-01-08 14:39:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,013 bytes |
| コンパイル時間 | 1,269 ms |
| コンパイル使用メモリ | 91,272 KB |
| 実行使用メモリ | 10,020 KB |
| 最終ジャッジ日時 | 2024-12-17 18:01:38 |
| 合計ジャッジ時間 | 21,850 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 TLE * 2 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using ll = long long;
using namespace std;
int main() {
int n; ll s; cin >> n >> s;
vector<ll> p(n); repeat (i,n) cin >> p[i];
vector<ll> acc { 0 }; whole(partial_sum, p, back_inserter(acc));
vector<vector<int> > result;
vector<int> path;
function<void (int, ll)> go = [&](int i, ll q) {
if (q == s) result.push_back(path);
if (q >= s) return;
if (q + acc[n] - acc[i] < s) return;
if (i == n) return;
go(i+1, q);
path.push_back(i);
go(i+1, q + p[i]);
path.pop_back();
};
go(0, 0);
whole(sort, result);
for (auto path : result) {
repeat (i,path.size()) cout << (i ? " " : "") << path[i]+1;
cout << endl;
}
return 0;
}