結果

問題 No.733 分身並列コーディング
ユーザー oshiborioshibori
提出日時 2018-09-23 05:58:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 75 ms / 1,500 ms
コード長 2,333 bytes
コンパイル時間 1,840 ms
コンパイル使用メモリ 170,420 KB
実行使用メモリ 16,524 KB
最終ジャッジ日時 2023-09-29 01:26:01
合計ジャッジ時間 5,367 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 75 ms
16,324 KB
testcase_04 AC 75 ms
16,428 KB
testcase_05 AC 29 ms
16,488 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 34 ms
16,296 KB
testcase_08 AC 32 ms
16,280 KB
testcase_09 AC 33 ms
9,584 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 5 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 17 ms
6,428 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 5 ms
4,376 KB
testcase_19 AC 34 ms
9,704 KB
testcase_20 AC 29 ms
9,652 KB
testcase_21 AC 18 ms
6,424 KB
testcase_22 AC 66 ms
16,524 KB
testcase_23 AC 16 ms
6,448 KB
testcase_24 AC 14 ms
6,408 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,384 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 35 ms
16,328 KB
testcase_29 AC 52 ms
16,524 KB
testcase_30 AC 51 ms
16,296 KB
testcase_31 AC 52 ms
16,460 KB
testcase_32 AC 6 ms
4,644 KB
testcase_33 AC 7 ms
4,804 KB
testcase_34 AC 7 ms
4,616 KB
testcase_35 AC 7 ms
4,628 KB
testcase_36 AC 7 ms
4,860 KB
testcase_37 AC 6 ms
4,652 KB
testcase_38 AC 45 ms
16,320 KB
testcase_39 AC 45 ms
16,500 KB
testcase_40 AC 44 ms
16,220 KB
testcase_41 AC 6 ms
4,628 KB
testcase_42 AC 7 ms
4,656 KB
testcase_43 AC 7 ms
4,716 KB
testcase_44 AC 47 ms
16,292 KB
testcase_45 AC 45 ms
16,492 KB
testcase_46 AC 45 ms
16,268 KB
testcase_47 AC 45 ms
16,292 KB
testcase_48 AC 46 ms
16,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]) == typeid(INF) and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int T;
  cin >> T;
  int N;
  cin >> N;
  vector<int> t(N);
  rep(i, 0, N) { cin >> t[i]; }
  vector<vector<int>> dp(1 << N, vector<int>(N + 1, INF));
  rep(i, 1, N + 1) dp[0][i] = 0;
  rep(bits, 0, 1 << N) {
    int sum = 0;
    rep(i, 0, N) {
      if (bits >> i & 1)
        sum += t[i];
    }
    dp[bits][0] = sum;
  }

  rep(bits, 1, 1 << N) rep(i, 1, N + 1) {
    if (dp[bits][i - 1] <= T)
      dp[bits][i] = 0;
    else {
      rep(j, 0, N) {
        if (bits >> j & 1) {
          chmin(dp[bits][i], dp[bits ^ (1 << j)][i] + t[j]);
        }
      }
    }
  }
  int ans = N;
  rep(i, 0, N) if (dp[(1 << N) - 1][i] == 0) chmin(ans, i);
  cout << ans << endl;

  return 0;
}
0