結果

問題 No.616 へんなソート
ユーザー Mr.Spock
提出日時 2021-02-09 23:34:29
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 945 bytes
コンパイル時間 639 ms
コンパイル使用メモリ 95,476 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-07 05:05:21
合計ジャッジ時間 7,243 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 TLE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <cstring>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin >> n >> k;
	vector<int>v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	vector<int>dp1(k + 1, 0);
	dp1[0] = 1;
	for (int i = 0; i < n; i++) {
		vector<int>dp2(k + 1, 0);
		for (int x = 0; x <= i; x++) {
			for (int y = 0; y + x <= k; y++) {
				dp2[x + y] += dp1[y];
				dp2[x + y] %= mod;
			}
		}
		swap(dp1, dp2);
	}
	int ans = 0;
	for (int i = 0; i <= k; i++) {
		ans += dp1[i];
		ans %= mod;
	}
	cout << ans << endl;
}
0