結果

問題 No.733 分身並列コーディング
ユーザー parukiparuki
提出日時 2018-09-11 00:01:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 280 ms / 1,500 ms
コード長 1,206 bytes
コンパイル時間 1,593 ms
コンパイル使用メモリ 164,528 KB
実行使用メモリ 4,680 KB
最終ジャッジ日時 2023-09-01 22:21:28
合計ジャッジ時間 8,432 ms
ジャッジサーバーID
(参考情報)
judge14 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 121 ms
4,380 KB
testcase_04 AC 121 ms
4,388 KB
testcase_05 AC 214 ms
4,416 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 220 ms
4,416 KB
testcase_08 AC 220 ms
4,416 KB
testcase_09 AC 54 ms
4,380 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 18 ms
4,376 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 5 ms
4,376 KB
testcase_19 AC 53 ms
4,380 KB
testcase_20 AC 63 ms
4,376 KB
testcase_21 AC 19 ms
4,508 KB
testcase_22 AC 160 ms
4,432 KB
testcase_23 AC 22 ms
4,380 KB
testcase_24 AC 27 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 3 ms
4,380 KB
testcase_28 AC 242 ms
4,440 KB
testcase_29 AC 223 ms
4,432 KB
testcase_30 AC 218 ms
4,388 KB
testcase_31 AC 231 ms
4,680 KB
testcase_32 AC 14 ms
4,376 KB
testcase_33 AC 12 ms
4,380 KB
testcase_34 AC 12 ms
4,376 KB
testcase_35 AC 12 ms
4,376 KB
testcase_36 AC 13 ms
4,380 KB
testcase_37 AC 11 ms
4,376 KB
testcase_38 AC 238 ms
4,440 KB
testcase_39 AC 248 ms
4,396 KB
testcase_40 AC 255 ms
4,420 KB
testcase_41 AC 12 ms
4,380 KB
testcase_42 AC 12 ms
4,380 KB
testcase_43 AC 11 ms
4,380 KB
testcase_44 AC 251 ms
4,380 KB
testcase_45 AC 254 ms
4,420 KB
testcase_46 AC 255 ms
4,488 KB
testcase_47 AC 280 ms
4,380 KB
testcase_48 AC 260 ms
4,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

const int MAX_N = 17;
int T, N, t[MAX_N], sm[1 << MAX_N], g[1 << MAX_N];

void solve() {
    cin >> T >> N;
    rep(i, N)cin >> t[i];

    rep(S, 1 << N) {
        g[S] = N;
        rep(i, N) if (S >> i & 1) sm[S] += t[i];
    }
    g[0] = 0;

    const int A = (1 << N) - 1;

    rep(S, 1 << N) {
        int U = A ^ S, V = U;
        do {
            if (sm[V] <= T) {
                smin(g[S | V], g[S] + 1);
            }
            V = (V - 1)&U;
        } while (U != V);
    }

    cout << g[A] << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}
0