結果

問題 No.695 square1001 and Permutation 4
ユーザー ei1333333ei1333333
提出日時 2018-06-08 22:54:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 661 bytes
コンパイル時間 2,010 ms
コンパイル使用メモリ 206,416 KB
実行使用メモリ 410,228 KB
最終ジャッジ日時 2023-09-30 01:20:39
合計ジャッジ時間 33,784 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 292 ms
5,668 KB
testcase_02 AC 470 ms
4,376 KB
testcase_03 AC 192 ms
4,376 KB
testcase_04 AC 1,439 ms
4,376 KB
testcase_05 MLE -
testcase_06 AC 2,789 ms
4,380 KB
testcase_07 AC 2,851 ms
4,380 KB
testcase_08 MLE -
testcase_09 MLE -
testcase_10 AC 564 ms
4,376 KB
testcase_11 MLE -
testcase_12 MLE -
testcase_13 AC 5,779 ms
47,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;

int N, M, X[5];
unordered_map< int, int64 > dp;
const int64 mod = 100000000000000007;

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

  dp[0] = 1;
  for(int k = 0; k < N; k++) {
    if(dp.count(k)) {
      for(int i = 0; i < M; i++) {
        if(k + X[i] < N) {
          dp[k + X[i]] += dp[k];
          if(dp[k + X[i]] >= mod) dp[k + X[i]] -= mod;
        }
      }

      if(k == N - 1) {
        cout << dp[N - 1] << endl;
        return 0;
      }
      dp.erase(k);
    }

    if(k == N - 1) {
      cout << dp[N - 1] << endl;
      return 0;
    }
  }
}
0