結果

問題 No.941 商とあまり
ユーザー chocoruskchocorusk
提出日時 2019-12-04 11:40:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,088 ms / 2,000 ms
コード長 1,982 bytes
コンパイル時間 1,110 ms
コンパイル使用メモリ 110,716 KB
実行使用メモリ 4,808 KB
最終ジャッジ日時 2023-08-20 03:16:08
合計ジャッジ時間 15,658 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
4,624 KB
testcase_01 AC 4 ms
4,376 KB
testcase_02 AC 4 ms
4,376 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 12 ms
4,580 KB
testcase_08 AC 12 ms
4,528 KB
testcase_09 AC 12 ms
4,624 KB
testcase_10 AC 46 ms
4,580 KB
testcase_11 AC 48 ms
4,528 KB
testcase_12 AC 56 ms
4,544 KB
testcase_13 AC 7 ms
4,380 KB
testcase_14 AC 1,088 ms
4,572 KB
testcase_15 AC 866 ms
4,552 KB
testcase_16 AC 588 ms
4,552 KB
testcase_17 AC 7 ms
4,380 KB
testcase_18 AC 5 ms
4,384 KB
testcase_19 AC 6 ms
4,376 KB
testcase_20 AC 4 ms
4,380 KB
testcase_21 AC 4 ms
4,376 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 108 ms
4,644 KB
testcase_27 AC 128 ms
4,624 KB
testcase_28 AC 1,086 ms
4,552 KB
testcase_29 AC 866 ms
4,612 KB
testcase_30 AC 870 ms
4,580 KB
testcase_31 AC 854 ms
4,624 KB
testcase_32 AC 5 ms
4,380 KB
testcase_33 AC 4 ms
4,380 KB
testcase_34 AC 5 ms
4,376 KB
testcase_35 AC 5 ms
4,380 KB
testcase_36 AC 55 ms
4,624 KB
testcase_37 AC 51 ms
4,544 KB
testcase_38 AC 28 ms
4,804 KB
testcase_39 AC 5 ms
4,380 KB
testcase_40 AC 4 ms
4,380 KB
testcase_41 AC 4 ms
4,376 KB
testcase_42 AC 3 ms
4,376 KB
testcase_43 AC 17 ms
4,564 KB
testcase_44 AC 16 ms
4,572 KB
testcase_45 AC 206 ms
4,576 KB
testcase_46 AC 159 ms
4,780 KB
testcase_47 AC 442 ms
4,620 KB
testcase_48 AC 4 ms
4,384 KB
testcase_49 AC 197 ms
4,588 KB
testcase_50 AC 14 ms
4,576 KB
testcase_51 AC 12 ms
4,644 KB
testcase_52 AC 10 ms
4,616 KB
testcase_53 AC 11 ms
4,576 KB
testcase_54 AC 263 ms
4,584 KB
testcase_55 AC 196 ms
4,808 KB
testcase_56 AC 235 ms
4,808 KB
testcase_57 AC 5 ms
4,380 KB
testcase_58 AC 5 ms
4,380 KB
testcase_59 AC 12 ms
4,620 KB
testcase_60 AC 12 ms
4,552 KB
testcase_61 AC 12 ms
4,576 KB
testcase_62 AC 5 ms
4,376 KB
testcase_63 AC 5 ms
4,376 KB
testcase_64 AC 5 ms
4,376 KB
testcase_65 AC 5 ms
4,380 KB
testcase_66 AC 48 ms
4,528 KB
testcase_67 AC 5 ms
4,380 KB
testcase_68 AC 50 ms
4,612 KB
testcase_69 AC 6 ms
4,380 KB
testcase_70 AC 5 ms
4,376 KB
testcase_71 AC 104 ms
4,552 KB
testcase_72 AC 103 ms
4,808 KB
testcase_73 AC 5 ms
4,380 KB
testcase_74 AC 5 ms
4,376 KB
testcase_75 AC 5 ms
4,380 KB
testcase_76 AC 5 ms
4,380 KB
testcase_77 AC 6 ms
4,376 KB
testcase_78 AC 5 ms
4,380 KB
testcase_79 AC 6 ms
4,380 KB
testcase_80 AC 5 ms
4,380 KB
testcase_81 AC 5 ms
4,380 KB
testcase_82 AC 5 ms
4,380 KB
testcase_83 AC 5 ms
4,380 KB
testcase_84 AC 6 ms
4,380 KB
testcase_85 AC 6 ms
4,376 KB
testcase_86 AC 6 ms
4,376 KB
testcase_87 AC 6 ms
4,376 KB
testcase_88 AC 6 ms
4,376 KB
testcase_89 AC 6 ms
4,380 KB
testcase_90 AC 6 ms
4,380 KB
testcase_91 AC 6 ms
4,380 KB
testcase_92 AC 6 ms
4,376 KB
testcase_93 AC 6 ms
4,376 KB
testcase_94 AC 5 ms
4,380 KB
testcase_95 AC 6 ms
4,376 KB
testcase_96 AC 6 ms
4,376 KB
testcase_97 AC 6 ms
4,380 KB
testcase_98 AC 4 ms
4,376 KB
testcase_99 AC 5 ms
4,376 KB
testcase_100 AC 6 ms
4,376 KB
testcase_101 AC 4 ms
4,380 KB
testcase_102 AC 4 ms
4,376 KB
testcase_103 AC 5 ms
4,380 KB
testcase_104 AC 2 ms
4,380 KB
testcase_105 AC 2 ms
4,380 KB
testcase_106 AC 2 ms
4,380 KB
testcase_107 AC 2 ms
4,380 KB
testcase_108 AC 2 ms
4,376 KB
testcase_109 AC 2 ms
4,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
    int n, x;
	cin>>n>>x;
	int a[101];
	int mn=x;
	for(int i=0; i<n; i++){
		cin>>a[i];
		mn=min(mn, a[i]);
	}
	string s;
	for(int i=0; i<x; i++) s+='0';
	if(n==1){
		if(a[0]<=x) s[a[0]-1]='1';
		cout<<s<<endl;
		return 0;
	}
	ll p=1;
	for(int i=0; i<n; i++){
		p*=(a[i]+1);
		if(p>=x+2){
			cout<<s<<endl;
			return 0;
		}
	}
	p--;
	bool dp[500050]={};
	for(int i=0; i<n; i++){
		for(int j=p; j<=x; j+=a[i]){
			dp[j]=1;
		}
	}
	if(mn==1 || n==2){
		for(int i=1; i<=x; i++) if(dp[i]) s[i-1]='1';
		cout<<s<<endl;
		return 0;
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(i==j) continue;
			bool dp1[500050]={};
			for(int k=p; k<=x; k+=a[j]) dp1[k]=1;
			for(int k=p; k<=x-a[i]*(a[j]+1); k++){
				if(dp1[k]) dp1[k+a[i]*(a[j]+1)]=1;
			}
			for(int k=p; k<=x; k++) if(dp1[k]) dp[k]=1;
		}
	}
	if(n==3){
		for(int i=1; i<=x; i++) if(dp[i]) s[i-1]='1';
		cout<<s<<endl;
		return 0;
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(i==j) continue;
			for(int l=0; l<n; l++){
				if(i==l || j==l) continue;
				bool dp1[500050]={};
				for(int k=p; k<=x; k+=a[l]) dp1[k]=1;
				for(int k=p; k<=x-a[j]*(a[l]+1); k++){
					if(dp1[k]) dp1[k+a[j]*(a[l]+1)]=1;
				}
				for(int k=p; k<=x-a[i]*(a[j]+1)*(a[l]+1); k++){
					if(dp1[k]) dp1[k+a[i]*(a[j]+1)*(a[l]+1)]=1;
				}
				for(int k=p; k<=x; k++) if(dp1[k]) dp[k]=1;
			}
		}
	}
	for(int i=1; i<=x; i++) if(dp[i]) s[i-1]='1';
	cout<<s<<endl;
    return 0;
}
0