結果
問題 | No.1457 ツブ消ししとるなHard |
ユーザー | Mister |
提出日時 | 2021-03-31 21:11:07 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 370 ms / 2,000 ms |
コード長 | 1,272 bytes |
コンパイル時間 | 940 ms |
コンパイル使用メモリ | 93,508 KB |
実行使用メモリ | 24,020 KB |
最終ジャッジ日時 | 2023-08-21 21:43:34 |
合計ジャッジ時間 | 2,187 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 370 ms
24,020 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 1 ms
4,376 KB |
testcase_09 | AC | 3 ms
4,380 KB |
testcase_10 | AC | 2 ms
4,380 KB |
testcase_11 | AC | 1 ms
4,376 KB |
testcase_12 | AC | 54 ms
7,560 KB |
testcase_13 | AC | 7 ms
4,376 KB |
testcase_14 | AC | 7 ms
4,380 KB |
testcase_15 | AC | 6 ms
4,376 KB |
testcase_16 | AC | 2 ms
4,380 KB |
testcase_17 | AC | 2 ms
4,384 KB |
testcase_18 | AC | 2 ms
4,376 KB |
testcase_19 | AC | 14 ms
4,672 KB |
testcase_20 | AC | 1 ms
4,376 KB |
ソースコード
#line 1 "main.cpp" #include <iostream> #include <algorithm> #include <numeric> #include <vector> #include <map> using namespace std; using lint = long long; void solve() { int n, m, l, r, z; cin >> n >> m >> r >> l >> z; vector<int> xs; int def = 0, cnt = 0; while (n--) { int x; cin >> x; if (x <= l) { continue; } else if (x >= r) { def += x - z; ++cnt; } else { xs.push_back(x - z); } } if (cnt > m) { cout << "Handicapped\n"; return; } n = xs.size(); map<tuple<int, int, int>, lint> dp; auto dfs = [&](auto&& f, int i, int sum, int num) -> lint { if (i == n) { return sum == 0 && 0 < num && num <= m ? 1 : 0; } auto t = make_tuple(i, sum, num); if (dp.count(t)) return dp[t]; auto& ret = dp[t]; ret = 0; for (int k = 0; k < 2; ++k) { auto nsum = sum + xs[i] * k; auto nnum = num + k; ret += f(f, i + 1, nsum, nnum); } return ret; }; cout << dfs(dfs, 0, def, cnt) << "\n"; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); solve(); return 0; }