結果

問題 No.616 へんなソート
ユーザー tailstails
提出日時 2017-12-16 01:29:28
言語 C++11
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 396 bytes
コンパイル時間 1,421 ms
コンパイル使用メモリ 159,456 KB
実行使用メモリ 13,644 KB
最終ジャッジ日時 2024-12-14 16:47:21
合計ジャッジ時間 13,812 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 TLE * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:13:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
   13 | main(){
      | ^~~~
main.cpp: In function ‘int main()’:
main.cpp:14:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |         scanf("%d%d",&n,&k);
      |         ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define M 1000000007

typedef long long ll;

int n,k,m,i,j,l,r;

int b[60000*2];
int*v=b,*w=b+60000;

main(){
	scanf("%d%d",&n,&k);
	v[0]=1;
	m=0;
	for(i=n;--i;){
		m+=i;
		for(j=0;j<=m;++j){
			w[j]=v[j];
			for(l=1;l<=i&&l<=j;++l){
				w[j]=(w[j]+v[j-l])%M;
			}
		}
		swap(v,w);
	}
	int r=0;
	for(;k>=0;--k){
		r=(r+v[k])%M;
	}
	printf("%d",r);
}
0