結果

問題 No.1633 Sorting Integers (Multiple of 2^K)
ユーザー 沙耶花沙耶花
提出日時 2021-07-30 22:20:13
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 927 bytes
コンパイル時間 4,225 ms
コンパイル使用メモリ 259,536 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-14 05:26:41
合計ジャッジ時間 7,914 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,352 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,352 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 2 ms
4,352 KB
testcase_16 AC 1 ms
4,352 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 1 ms
4,352 KB
testcase_19 AC 2 ms
4,352 KB
testcase_20 AC 2 ms
4,352 KB
testcase_21 AC 1 ms
4,352 KB
testcase_22 AC 2 ms
4,352 KB
testcase_23 AC 146 ms
4,352 KB
testcase_24 AC 158 ms
4,352 KB
testcase_25 AC 167 ms
4,348 KB
testcase_26 AC 147 ms
4,352 KB
testcase_27 AC 156 ms
4,352 KB
testcase_28 AC 131 ms
4,348 KB
testcase_29 AC 156 ms
4,356 KB
testcase_30 AC 131 ms
4,356 KB
testcase_31 AC 146 ms
4,352 KB
testcase_32 AC 97 ms
4,352 KB
testcase_33 AC 7 ms
4,352 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 8 ms
4,352 KB
testcase_36 AC 4 ms
4,352 KB
testcase_37 AC 12 ms
4,352 KB
testcase_38 AC 58 ms
4,348 KB
testcase_39 AC 7 ms
4,352 KB
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 41 ms
4,352 KB
testcase_42 AC 3 ms
4,348 KB
testcase_43 AC 7 ms
4,348 KB
testcase_44 AC 63 ms
4,348 KB
testcase_45 AC 22 ms
4,348 KB
testcase_46 AC 3 ms
4,356 KB
testcase_47 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000005

int ans = 0;
int n;
vector<int> c;
vector<long long> B(17,0);
void dfs(int b,long long cur){
int m = __builtin_popcount(b);
	{
		
		if(m==n){
			long long cc = 1LL;
			rep(i,50){
				if(cur%cc==0)ans = max(ans,i);
				else break;
				cc *= 2;
			}
			return;
		}
		else{
			if(cur % (1<<m) != 0)return;
			else ans = max(ans,m);
		}
	}

	rep(i,n){
		if((b>>i)&1)continue;
		//cout<<i<<endl;
		//cout<<c[i]<<endl;
		if(i!=0&&(((b>>(i-1))&1)==0)&&c[i]==c[i-1])continue;
		
		dfs(b|(1<<i),c[i]*B[m] + cur);
	}
	
	
}

int main(){
	
	cin>>n;
	//vector<int> c;
	rep(i,9){
		int t;
		cin>>t;
		
		rep(j,t)c.push_back(i+1);
	}
	
	B[0] = 1;
	rep(i,16){
		B[i+1] = B[i]*10;
	}
	
	dfs(0,0);
	cout<<ans<<endl;
	
	return 0;
}
0