結果

問題 No.616 へんなソート
ユーザー pekempeypekempey
提出日時 2017-12-16 06:55:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 541 bytes
コンパイル時間 701 ms
コンパイル使用メモリ 72,968 KB
実行使用メモリ 8,528 KB
最終ジャッジ日時 2023-08-21 07:55:08
合計ジャッジ時間 6,450 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,188 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 4 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 8 ms
4,380 KB
testcase_13 AC 959 ms
4,380 KB
testcase_14 AC 6 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 440 ms
4,376 KB
testcase_18 AC 41 ms
4,380 KB
testcase_19 AC 49 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 11 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 TLE -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const long long mod = 1e9 + 7;

int main() {
  int n, K;
  cin >> n >> K;

  vector<long long> dp0(K + 1);
  dp0[0] = 1;

  for (int i = 0; i < n; i++) {
    vector<long long> dp1(K + 1);
    for (int j = 0; j <= K; j++) {
      for (int k = 0; k <= i && j + k <= K; k++) {
        (dp1[j + k] += dp0[j]) %= mod;
      }
    }
    dp0 = dp1;
  }

  long long ans = 0;
  for (int i = 0; i <= K; i++) {
    (ans += dp0[i]) %= mod;
  }

  cout << ans << endl;
}
0