結果
問題 | No.1001 注文の多い順列 |
ユーザー | chocorusk |
提出日時 | 2020-02-28 22:07:46 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 74 ms / 2,000 ms |
コード長 | 1,276 bytes |
コンパイル時間 | 1,220 ms |
コンパイル使用メモリ | 116,104 KB |
実行使用メモリ | 75,420 KB |
最終ジャッジ日時 | 2024-04-21 19:01:45 |
合計ジャッジ時間 | 3,990 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 29 ms
75,264 KB |
testcase_01 | AC | 30 ms
75,364 KB |
testcase_02 | AC | 28 ms
75,232 KB |
testcase_03 | AC | 29 ms
75,264 KB |
testcase_04 | AC | 29 ms
75,284 KB |
testcase_05 | AC | 29 ms
75,392 KB |
testcase_06 | AC | 28 ms
75,264 KB |
testcase_07 | AC | 29 ms
75,252 KB |
testcase_08 | AC | 30 ms
75,136 KB |
testcase_09 | AC | 28 ms
75,236 KB |
testcase_10 | AC | 29 ms
75,264 KB |
testcase_11 | AC | 28 ms
75,312 KB |
testcase_12 | AC | 28 ms
75,288 KB |
testcase_13 | AC | 28 ms
75,264 KB |
testcase_14 | AC | 28 ms
75,384 KB |
testcase_15 | AC | 28 ms
75,264 KB |
testcase_16 | AC | 28 ms
75,392 KB |
testcase_17 | AC | 28 ms
75,264 KB |
testcase_18 | AC | 41 ms
75,332 KB |
testcase_19 | AC | 40 ms
75,392 KB |
testcase_20 | AC | 36 ms
75,236 KB |
testcase_21 | AC | 35 ms
75,264 KB |
testcase_22 | AC | 44 ms
75,196 KB |
testcase_23 | AC | 59 ms
75,264 KB |
testcase_24 | AC | 44 ms
75,264 KB |
testcase_25 | AC | 74 ms
75,392 KB |
testcase_26 | AC | 48 ms
75,392 KB |
testcase_27 | AC | 48 ms
75,264 KB |
testcase_28 | AC | 47 ms
75,392 KB |
testcase_29 | AC | 40 ms
75,356 KB |
testcase_30 | AC | 40 ms
75,392 KB |
testcase_31 | AC | 40 ms
75,180 KB |
testcase_32 | AC | 37 ms
75,268 KB |
testcase_33 | AC | 49 ms
75,420 KB |
ソースコード
#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <complex> #include <unordered_map> #include <unordered_set> #include <random> #include <cassert> #include <fstream> #include <utility> #include <functional> #include <time.h> #include <stack> #include <array> #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair<int, int> P; const ll MOD=1e9+7; int main() { int n; cin>>n; vector<int> x0, x1; for(int i=0; i<n; i++){ int x, t; cin>>t>>x; x--; if(t==0) x0.push_back(x); else x1.push_back(x); } sort(x0.begin(), x0.end()); sort(x1.begin(), x1.end()); int c0[3030], c1[3030]; for(int i=0; i<n; i++){ c0[i]=lower_bound(x0.begin(), x0.end(), i)-x0.begin(); c1[i]=upper_bound(x1.begin(), x1.end(), i)-x1.begin(); c0[i]=(int)x0.size()-c0[i]; } ll dp[3030][3030]={}; dp[0][0]=1; for(int i=0; i<n; i++){ for(int j=0; j<=i; j++){ if(c1[i]-j>0) (dp[i+1][j+1]+=dp[i][j]*(c1[i]-j))%=MOD; if(c0[i]-(int)x0.size()+1+i-j>0) (dp[i+1][j]+=dp[i][j]*(c0[i]-(int)x0.size()+1+i-j))%=MOD; } } cout<<dp[n][(int)x1.size()]<<endl; return 0; }