結果

問題 No.1001 注文の多い順列
ユーザー kotatsugamekotatsugame
提出日時 2020-02-28 22:51:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 736 bytes
コンパイル時間 1,044 ms
コンパイル使用メモリ 76,548 KB
実行使用メモリ 23,296 KB
最終ジャッジ日時 2024-04-21 20:03:03
合計ジャッジ時間 3,273 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 161 ms
16,512 KB
testcase_19 AC 144 ms
15,360 KB
testcase_20 AC 91 ms
12,032 KB
testcase_21 AC 81 ms
11,264 KB
testcase_22 AC 196 ms
18,304 KB
testcase_23 AC 196 ms
18,560 KB
testcase_24 AC 194 ms
18,304 KB
testcase_25 AC 193 ms
18,176 KB
testcase_26 AC 3 ms
5,376 KB
testcase_27 AC 18 ms
6,016 KB
testcase_28 AC 32 ms
8,320 KB
testcase_29 AC 49 ms
20,608 KB
testcase_30 AC 60 ms
21,376 KB
testcase_31 AC 73 ms
23,296 KB
testcase_32 AC 16 ms
15,616 KB
testcase_33 AC 4 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N;
vector<int>X[2];
long mod=1e9+7,dp[3030][3030];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int t,x;cin>>t>>x;
		X[t].push_back(x);
	}
	for(int i=0;i<2;i++)sort(X[i].begin(),X[i].end());
	dp[0][0]=1;
	for(int i=0;i<=X[0].size();i++)for(int j=0;j<=X[1].size()&&i+j<N;j++)
	{
		int x=i+j+1;
		if(i<X[0].size())
		{
			int l=lower_bound(X[0].begin(),X[0].end(),x)-X[0].begin();
			if(l<=i)
			{
				(dp[i+1][j]+=dp[i][j]*(i-l+1))%=mod;
			}
		}
		if(j<X[1].size())
		{
			int l=upper_bound(X[1].begin(),X[1].end(),x)-X[1].begin();
			l--;
			if(j<=l)
			{
				(dp[i][j+1]+=dp[i][j]*(l-j+1))%=mod;
			}
		}
	}
	cout<<dp[X[0].size()][X[1].size()]<<endl;
}
0