結果

問題 No.616 へんなソート
ユーザー Sebastian KingSebastian King
提出日時 2017-12-16 00:22:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 463 bytes
コンパイル時間 2,895 ms
コンパイル使用メモリ 144,252 KB
実行使用メモリ 60,176 KB
最終ジャッジ日時 2023-08-21 06:54:17
合計ジャッジ時間 3,572 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
5,400 KB
testcase_03 AC 2 ms
7,460 KB
testcase_04 AC 3 ms
9,512 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
7,492 KB
testcase_07 AC 2 ms
5,416 KB
testcase_08 AC 3 ms
9,544 KB
testcase_09 AC 3 ms
11,536 KB
testcase_10 AC 2 ms
5,484 KB
testcase_11 AC 3 ms
9,600 KB
testcase_12 AC 4 ms
17,772 KB
testcase_13 AC 17 ms
50,452 KB
testcase_14 AC 3 ms
13,640 KB
testcase_15 AC 2 ms
5,448 KB
testcase_16 AC 3 ms
11,712 KB
testcase_17 AC 15 ms
48,400 KB
testcase_18 AC 10 ms
36,248 KB
testcase_19 AC 9 ms
34,108 KB
testcase_20 AC 3 ms
9,492 KB
testcase_21 AC 3 ms
13,628 KB
testcase_22 AC 7 ms
26,124 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 6 ms
23,948 KB
testcase_27 AC 6 ms
23,828 KB
testcase_28 AC 24 ms
60,176 KB
testcase_29 AC 24 ms
59,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int n,m,M=1e9+7,ans=0;
int f[302][50000];
void upd(int&x,int y){x+=y;if(x>=M)x-=M;}
int main(){
	std::ios::sync_with_stdio(false);
	cin>>n>>m;
	f[1][0]=f[2][0]=f[2][1]=1;
	for(int i=3,q=3;i<=n;i++,q+=i){
		int l=0;
		for(int k=0;k<i;k++)upd(l,f[i-1][k]),f[i][k]=l;
		for(int j=i;j<=q;j++){upd(l,f[i-1][j]),l-=f[i-1][j-i];if(l<0)l+=M;f[i][j]=l;}
	}
	for(int i=0;i<=m;i++)upd(ans,f[n][i]);
	cout<<ans<<endl;
	return 0;
}
0