Submission #4293711


Source Code Expand

Copy
#include <bits/stdc++.h>

using namespace std;

int N, M;
int A[10];
int num[] = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string dp[10010];


int main() {
  cin >> N >> M;
  for(int i=0; i<M; ++i) {
    cin >> A[i];
  }

  for(int i=0; i<=N; ++i) {
    for(int j=0; j<M; ++j) {
      int n = num[A[j]];
      string tmp;
      stringstream ss;

      if(i < n) continue;
      if(i == n) ss << A[j];
      else if(dp[i-n] != "") ss << A[j] << dp[i-n];
      else continue;
      ss >> tmp;
      if(tmp.size() > dp[i].size() || (tmp.size() == dp[i].size() && tmp > dp[i])) {
        dp[i] = tmp;
      }
    }
  }
  cout << dp[N] << endl;
}

Submission Info

Submission Time
Task D - Match Matching
User kivantium
Language C++14 (GCC 5.4.1)
Score 400
Code Size 665 Byte
Status
Exec Time 299 ms
Memory 49024 KB

Test Cases

Set Name Score / Max Score Test Cases
All 400 / 400 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 0 / 0 sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
0_random_1 2 ms 384 KB
0_random_2 1 ms 256 KB
0_random_3 15 ms 1280 KB
0_random_4 116 ms 47360 KB
0_random_5 186 ms 34304 KB
0_random_6 99 ms 22784 KB
0_random_7 7 ms 1792 KB
0_random_8 2 ms 384 KB
1_normal_1 24 ms 3072 KB
1_normal_2 92 ms 12416 KB
1_normal_3 36 ms 4864 KB
1_normal_4 123 ms 31616 KB
1_normal_5 67 ms 35584 KB
1_normal_6 51 ms 4864 KB
2_corner_1 22 ms 2176 KB
2_corner_2 3 ms 384 KB
2_corner_3 57 ms 9088 KB
2_corner_4 7 ms 768 KB
2_corner_5 4 ms 384 KB
2_corner_6 18 ms 2688 KB
3_hand_1 42 ms 12288 KB
3_hand_2 1 ms 384 KB
3_hand_3 1 ms 384 KB
3_hand_4 1 ms 384 KB
3_hand_5 1 ms 384 KB
3_hand_6 299 ms 49024 KB
sample_01 1 ms 384 KB
sample_02 2 ms 384 KB
sample_03 1 ms 384 KB