結果

問題 No.733 分身並列コーディング
コンテスト
ユーザー 梧桐
提出日時 2026-01-27 00:03:43
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
結果
WA  
実行時間 -
コード長 956 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,064 ms
コンパイル使用メモリ 110,484 KB
実行使用メモリ 7,976 KB
最終ジャッジ日時 2026-01-27 00:03:46
合計ジャッジ時間 2,942 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 46
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <random>

using namespace std;

const int N = 20;

int t, n, ans;
vector<int> a;
bool st[N];
mt19937_64 rng(5201314);

int main() {
    freopen("clone.in", "r", stdin);
    freopen("clone.out", "w", stdout);

    scanf("%d%d", &t, &n);
    for (int i = 1, x; i <= n; ++i) {
        scanf("%d", &x);
        a.push_back(x);
    }

    ans = n;
    for (int lucky = 0; lucky < 200000; ++lucky) {
        shuffle(a.begin(), a.end(), rng);
        memset(st, 0, sizeof(st));
        int v = 0, cnt = 0;
        while (cnt < n) {
            int cur = 0;
            for (int i = 0; i < n; ++i) {
                if (!st[i] && cur + a[i] <= t) {
                    cur += a[i];
                    ++cnt;
                    st[i] = true;
                }
            }
            ++v;
        }
        ans = min(ans, v);
    }
    printf("%d\n", ans);

    return 0;
}
0