結果

問題 No.1633 Sorting Integers (Multiple of 2^K)
ユーザー SSRSSSRS
提出日時 2021-07-30 21:12:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 787 bytes
コンパイル時間 1,598 ms
コンパイル使用メモリ 167,992 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-14 02:40:06
合計ジャッジ時間 30,944 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 2 ms
4,356 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,356 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 2 ms
4,352 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,352 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 1,793 ms
4,352 KB
testcase_24 AC 1,956 ms
4,348 KB
testcase_25 TLE -
testcase_26 AC 1,773 ms
4,352 KB
testcase_27 AC 1,917 ms
4,348 KB
testcase_28 AC 1,600 ms
4,352 KB
testcase_29 AC 1,925 ms
4,348 KB
testcase_30 AC 1,604 ms
4,352 KB
testcase_31 AC 1,771 ms
4,352 KB
testcase_32 AC 1,162 ms
4,348 KB
testcase_33 AC 1,374 ms
4,348 KB
testcase_34 AC 37 ms
4,348 KB
testcase_35 AC 44 ms
4,352 KB
testcase_36 AC 50 ms
4,352 KB
testcase_37 AC 175 ms
4,348 KB
testcase_38 TLE -
testcase_39 AC 51 ms
4,348 KB
testcase_40 AC 29 ms
4,348 KB
testcase_41 TLE -
testcase_42 AC 68 ms
4,348 KB
testcase_43 AC 264 ms
4,352 KB
testcase_44 AC 1,541 ms
4,348 KB
testcase_45 TLE -
testcase_46 AC 32 ms
4,352 KB
testcase_47 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0