結果
| 問題 | No.733 分身並列コーディング |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-01-27 00:02:27 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 768 ms / 1,500 ms |
| コード長 | 879 bytes |
| 記録 | |
| コンパイル時間 | 1,007 ms |
| コンパイル使用メモリ | 110,604 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2026-01-27 00:02:50 |
| 合計ジャッジ時間 | 23,054 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 46 |
ソースコード
#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(114514);
int main() {
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 < 1000000; ++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;
}