結果
問題 | No.1463 Hungry Kanten |
ユーザー | arashin |
提出日時 | 2021-04-02 22:38:04 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,757 bytes |
コンパイル時間 | 1,906 ms |
コンパイル使用メモリ | 178,628 KB |
実行使用メモリ | 12,136 KB |
最終ジャッジ日時 | 2023-08-25 15:03:02 |
合計ジャッジ時間 | 3,250 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 105 ms
12,096 KB |
testcase_06 | AC | 2 ms
4,380 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 2 ms
4,376 KB |
testcase_11 | AC | 2 ms
4,376 KB |
testcase_12 | AC | 2 ms
4,380 KB |
testcase_13 | AC | 2 ms
4,380 KB |
testcase_14 | AC | 3 ms
4,380 KB |
testcase_15 | AC | 2 ms
4,380 KB |
testcase_16 | AC | 6 ms
4,380 KB |
testcase_17 | AC | 14 ms
4,380 KB |
testcase_18 | AC | 6 ms
4,380 KB |
testcase_19 | AC | 55 ms
7,024 KB |
testcase_20 | AC | 75 ms
12,136 KB |
testcase_21 | AC | 2 ms
4,376 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; using u64 = uint_least64_t; using s64 = int_least64_t; using ll = uint_least64_t; void recursive_comb(vector<int> &indexes, int s, int rest, vector<vector<int>> &com) { if (rest == 0) { vector<int> v; for (int i = 0; i < indexes.size(); i++){ v.push_back(indexes[i]); } com.push_back(v); // cout << "out(rest==0)" << endl; } else { if (s < 0) { return; } recursive_comb(indexes, s - 1, rest, com); indexes[rest - 1] = s; recursive_comb(indexes, s - 1, rest - 1, com); } } // nCkの組み合わせに対して処理を実行する void foreach_comb(int n, int k, vector<int> &indexes, vector<vector<int>> &com) { recursive_comb(indexes, n - 1, k, com); } int main(){ u64 n,k ; vector<vector<int>> com; vector<int> indexes; vector<u64> ans; cin >> n >> k; vector<u64> a(n); for (int i = 0; i < n; i++){ cin >> a[i]; } for (int i = k; i <= n; i++){ u64 sum = 0; u64 prd = 1; indexes.clear(); com.clear(); for (int j = 0; j < i; j++){ indexes.push_back(j); } foreach_comb(n, i, indexes, com); for (int ii = 0; ii < com.size(); ii++){ for (int jj = 0; jj < com.at(ii).size(); jj++){ sum += a[com.at(ii).at(jj)]; prd *= a[com.at(ii).at(jj)]; } ans.push_back(sum); ans.push_back(prd); sum = 0; prd = 1; } } std::sort(ans.begin(), ans.end()); ans.erase(std::unique(ans.begin(), ans.end()), ans.end()); cout << ans.size() << endl; return 0; }