Contest Duration: - (local time) (100 minutes) Back to Home

Submission #4282921

Source Code Expand

Copy
```#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
bool dp[5010][10010];
int a[10]={0,2,5,5,4,5,6,3,7,6};
int main()
{
int n,m,x;vector<int> v;
cin>>n>>m;
rep(i,m){
cin>>x;v.pb(x);
}
sort(All(v));reverse(All(v));
memset(dp,false,sizeof(dp));
dp[0][0]=1;
rep(i,5005) rep(j,n+1){
if(!dp[i][j]) continue;
rep(k,m) dp[i+1][j+a[v[k]]]=true;
}
int d=0;
rep(i,5005){
if(dp[i][n]) d=max(d,i);
}
string out="";
for(int i=d;i>0;i--){
x=0;
rep(j,m){
if(dp[i-1][n-a[v[j]]]) x=max(x,v[j]);
}
out+=('0'+x);n-=a[x];
}
cout<<out<<endl;
}
```

#### Submission Info

Submission Time 2019-02-16 21:12:48+0900 D - Match Matching sky58 C++14 (GCC 5.4.1) 400 1509 Byte AC 174 ms 49280 KB

#### Judge Result

Set Name All Sample
Score / Max Score 400 / 400 0 / 0
Status
 AC × 29
 AC × 3
Set Name Test Cases
All 0_random_1, 0_random_2, 0_random_3, 0_random_4, 0_random_5, 0_random_6, 0_random_7, 0_random_8, 1_normal_1, 1_normal_2, 1_normal_3, 1_normal_4, 1_normal_5, 1_normal_6, 2_corner_1, 2_corner_2, 2_corner_3, 2_corner_4, 2_corner_5, 2_corner_6, 3_hand_1, 3_hand_2, 3_hand_3, 3_hand_4, 3_hand_5, 3_hand_6, sample_01, sample_02, sample_03
Sample sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
0_random_1 AC 14 ms 49152 KB
0_random_2 AC 14 ms 49152 KB
0_random_3 AC 23 ms 49280 KB
0_random_4 AC 89 ms 49280 KB
0_random_5 AC 93 ms 49280 KB
0_random_6 AC 65 ms 49280 KB
0_random_7 AC 37 ms 49280 KB
0_random_8 AC 20 ms 49280 KB
1_normal_1 AC 30 ms 49280 KB
1_normal_2 AC 55 ms 49280 KB
1_normal_3 AC 36 ms 49280 KB
1_normal_4 AC 77 ms 49280 KB
1_normal_5 AC 47 ms 49280 KB
1_normal_6 AC 38 ms 49280 KB
2_corner_1 AC 27 ms 49280 KB
2_corner_2 AC 17 ms 49152 KB
2_corner_3 AC 46 ms 49280 KB
2_corner_4 AC 21 ms 49280 KB
2_corner_5 AC 16 ms 49280 KB
2_corner_6 AC 29 ms 49280 KB
3_hand_1 AC 49 ms 49280 KB
3_hand_2 AC 14 ms 49280 KB
3_hand_3 AC 14 ms 49152 KB
3_hand_4 AC 14 ms 49280 KB
3_hand_5 AC 14 ms 49280 KB
3_hand_6 AC 174 ms 49280 KB
sample_01 AC 14 ms 49152 KB
sample_02 AC 15 ms 49152 KB
sample_03 AC 14 ms 49280 KB