結果
問題 | No.1633 Sorting Integers (Multiple of 2^K) |
ユーザー |
![]() |
提出日時 | 2021-07-30 21:12:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,880 ms / 2,000 ms |
コード長 | 787 bytes |
コンパイル時間 | 1,582 ms |
コンパイル使用メモリ | 169,016 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-15 22:18:41 |
合計ジャッジ時間 | 27,786 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 |
ソースコード
#include <bits/stdc++.h>using namespace std;int dfs(vector<int> &A, int S, int d, long long x){int N = A.size();if (d == N){return __builtin_ctzll(x);} else {int ans = d;long long a = 1;for (int i = 0; i < d; i++){a *= 10;}for (int i = 0; i < N; i++){if ((S >> i & 1) == 0){long long x2 = x + A[i] * a;if (__builtin_ctzll(x2) >= d + 1){ans = max(ans, dfs(A, S + (1 << i), d + 1, x2));}}}return ans;}}int main(){int N;cin >> N;vector<int> c(10);c[0] = 0;for (int i = 1; i < 10; i++){cin >> c[i];}vector<int> A;for (int i = 1; i < 10; i++){for (int j = 0; j < c[i]; j++){A.push_back(i);}}cout << dfs(A, 0, 0, 0) << endl;}