結果

問題 No.794 チーム戦 (2)
ユーザー ei1333333ei1333333
提出日時 2018-10-06 01:29:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 578 bytes
コンパイル時間 1,892 ms
コンパイル使用メモリ 196,980 KB
実行使用メモリ 29,860 KB
最終ジャッジ日時 2024-04-20 17:34:35
合計ジャッジ時間 5,550 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,752 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 141 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 8 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 40 ms
5,376 KB
testcase_11 AC 7 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

int main() {
  int N, K;
  cin >> N >> K;
  vector< int > A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  function< int(int, int) > dfs = [&](int idx, int bit) {
    if(idx == N) return 1;
    if((bit >> idx) & 1) return dfs(idx + 1, bit);
    int ret = 0;
    for(int i = idx + 1; i < N; i++) {
      if((bit >> i) & 1) continue;
      if(A[idx] + A[i] <= K) (ret += dfs(idx + 1, bit | (1 << idx) | (1 << i))) %= mod;
    }
    return ret;
  };
  cout << dfs(0, 0) << endl;
}
0