結果

問題 No.616 へんなソート
ユーザー Sebastian KingSebastian King
提出日時 2017-12-16 00:15:46
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 1,159 bytes
コンパイル時間 1,691 ms
コンパイル使用メモリ 144,644 KB
実行使用メモリ 60,020 KB
最終ジャッジ日時 2023-08-21 06:51:41
合計ジャッジ時間 2,713 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
5,440 KB
testcase_03 AC 3 ms
7,452 KB
testcase_04 AC 3 ms
9,508 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
7,476 KB
testcase_07 AC 2 ms
5,720 KB
testcase_08 AC 3 ms
9,816 KB
testcase_09 AC 3 ms
11,596 KB
testcase_10 AC 2 ms
5,420 KB
testcase_11 AC 3 ms
9,508 KB
testcase_12 AC 5 ms
17,728 KB
testcase_13 AC 18 ms
50,484 KB
testcase_14 AC 4 ms
13,780 KB
testcase_15 AC 2 ms
5,420 KB
testcase_16 AC 3 ms
11,596 KB
testcase_17 AC 16 ms
48,420 KB
testcase_18 AC 10 ms
36,148 KB
testcase_19 AC 9 ms
34,084 KB
testcase_20 AC 3 ms
9,576 KB
testcase_21 AC 4 ms
13,668 KB
testcase_22 AC 7 ms
26,120 KB
testcase_23 AC 1 ms
4,384 KB
testcase_24 AC 1 ms
4,384 KB
testcase_25 AC 2 ms
4,384 KB
testcase_26 AC 6 ms
24,016 KB
testcase_27 AC 6 ms
23,956 KB
testcase_28 AC 24 ms
59,956 KB
testcase_29 AC 24 ms
60,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

void prework(){

}

void read(){

}

int f[302][50000];
void upd(int &x, int y){
	x += y;
	if (x >= MM) x -= MM;
}

void solve(int casi){
//	cout << "Case #" << casi << ": ";
	cin >> n >> m;
	f[1][0] = 1;
	f[2][0] = 1; f[2][1] = 1;
	// f[p][q] p ge shu, nixudui wei q
	for (int i = 3; i <= n; i++){
		int p = (i - 2) * (i - 1) / 2;
		int q = (i - 1) * i / 2;
		int tmp = 0;
		for (int k = 0; k < i; k++){
			upd(tmp, f[i-1][k]);
			f[i][k] = tmp;
		}
		for (int j = i; j <= q; j++){
			upd(tmp, f[i-1][j]);
			tmp -= f[i-1][j-i];
			if (tmp < 0) tmp += MM;
			f[i][j] = tmp;
		}
		
		/*
		for (int j = 0; j <= p; j++){
			for (int k = 0; k < i; k++)
				upd(f[i][j + k], f[i - 1][j]);
		}*/
	}
	int ans = 0;
	for (int i = 0; i <= m; i++)
		upd(ans, f[n][i]);
	cout << ans << endl;
}

void printans(){

}


int main(){
//	std::ios::sync_with_stdio(false);
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}

0