結果
問題 |
No.733 分身並列コーディング
|
ユーザー |
|
提出日時 | 2018-09-07 21:58:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,235 bytes |
コンパイル時間 | 1,911 ms |
コンパイル使用メモリ | 201,272 KB |
最終ジャッジ日時 | 2025-01-06 12:57:26 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 WA * 24 |
ソースコード
//================================= // Created on: 2018/09/07 21:49:21 //================================= #include <bits/stdc++.h> #define show(x) std::cerr << #x << " = " << x << std::endl using ll = long long; using ull = unsigned long long; using ld = long double; constexpr ll MOD = 1000000007LL; template <typename T> constexpr T INF = std::numeric_limits<T>::max() / 10; std::mt19937 mt{std::random_device{}()}; int main() { int T, N; std::cin >> T >> N; std::vector<int> t(N); for (int i = 0; i < N; i++) { std::cin >> t[i]; } std::sort(t.begin(), t.end(), std::greater<int>{}); auto check = [&](const int n) { std::priority_queue<int, std::vector<int>, std::greater<int>> q; for (int i = 0; i < n; i++) { q.push(0); } for (int i = 0; i < N; i++) { const int p = q.top(); q.pop(); q.push(p + t[i]); } while (not q.empty()) { if (q.top() > T) { return false; } q.pop(); } return true; }; int inf = 0, sup = N + 1; while (sup - inf > 1) { const int mid = (inf + sup) / 2; (check(mid) ? sup : inf) = mid; } std::cout << sup << std::endl; return 0; }