# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
349289 | 2021-01-17T10:45:09 Z | denkendoemeer | Boat (APIO16_boat) | C++14 | 1451 ms | 4480 KB |
#include<bits/stdc++.h> #define ll long long using namespace std; #define mod 1000000007 vector<int>aux; array<int,2>v[505]; ll dp[1005][505],inv[505]; int main() { //freopen(".in","r",stdin); //freopen(".out","w",stdout); int n,i,j,e; scanf("%d",&n); aux={-1}; inv[1]=1; for(i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod; for(i=1;i<=n;i++){ scanf("%d%d",&v[i][0],&v[i][1]); ++v[i][1]; aux.push_back(v[i][0]); aux.push_back(v[i][1]); } sort(aux.begin(),aux.end()); aux.resize(unique(aux.begin(),aux.end())-aux.begin()); int m=aux.size(); for(i=0;i<m;i++) dp[i][0]=1; for(i=1;i<=n;i++){ for(j=m-1;j>=1;j--) if (v[i][0]<=aux[j-1] && aux[j]<=v[i][1]){ int cnt=aux[j]-aux[j-1]; for(e=min(cnt,i);e>=1;e--) dp[j][e]=(dp[j][e]+dp[j][e-1]*(cnt-e+1)%mod*inv[e])%mod; } for(j=1;j<=m;j++){ dp[j][0]=0; for(e=0;e<=n;e++) dp[j][0]=(dp[j][0]+dp[j-1][e])%mod; } } printf("%lld\n",(dp[m][0]+mod-1)%mod); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1149 ms | 4356 KB | Output is correct |
2 | Correct | 1153 ms | 4332 KB | Output is correct |
3 | Correct | 1153 ms | 4352 KB | Output is correct |
4 | Correct | 1154 ms | 4356 KB | Output is correct |
5 | Correct | 1152 ms | 4460 KB | Output is correct |
6 | Correct | 1151 ms | 4460 KB | Output is correct |
7 | Correct | 1161 ms | 4356 KB | Output is correct |
8 | Correct | 1164 ms | 4480 KB | Output is correct |
9 | Correct | 1190 ms | 4460 KB | Output is correct |
10 | Correct | 1153 ms | 4352 KB | Output is correct |
11 | Correct | 1148 ms | 4460 KB | Output is correct |
12 | Correct | 1153 ms | 4460 KB | Output is correct |
13 | Correct | 1157 ms | 4460 KB | Output is correct |
14 | Correct | 1170 ms | 4356 KB | Output is correct |
15 | Correct | 1157 ms | 4332 KB | Output is correct |
16 | Correct | 208 ms | 1004 KB | Output is correct |
17 | Correct | 220 ms | 1260 KB | Output is correct |
18 | Correct | 211 ms | 1132 KB | Output is correct |
19 | Correct | 220 ms | 1132 KB | Output is correct |
20 | Correct | 212 ms | 1132 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1149 ms | 4356 KB | Output is correct |
2 | Correct | 1153 ms | 4332 KB | Output is correct |
3 | Correct | 1153 ms | 4352 KB | Output is correct |
4 | Correct | 1154 ms | 4356 KB | Output is correct |
5 | Correct | 1152 ms | 4460 KB | Output is correct |
6 | Correct | 1151 ms | 4460 KB | Output is correct |
7 | Correct | 1161 ms | 4356 KB | Output is correct |
8 | Correct | 1164 ms | 4480 KB | Output is correct |
9 | Correct | 1190 ms | 4460 KB | Output is correct |
10 | Correct | 1153 ms | 4352 KB | Output is correct |
11 | Correct | 1148 ms | 4460 KB | Output is correct |
12 | Correct | 1153 ms | 4460 KB | Output is correct |
13 | Correct | 1157 ms | 4460 KB | Output is correct |
14 | Correct | 1170 ms | 4356 KB | Output is correct |
15 | Correct | 1157 ms | 4332 KB | Output is correct |
16 | Correct | 208 ms | 1004 KB | Output is correct |
17 | Correct | 220 ms | 1260 KB | Output is correct |
18 | Correct | 211 ms | 1132 KB | Output is correct |
19 | Correct | 220 ms | 1132 KB | Output is correct |
20 | Correct | 212 ms | 1132 KB | Output is correct |
21 | Correct | 1059 ms | 3948 KB | Output is correct |
22 | Correct | 1073 ms | 4076 KB | Output is correct |
23 | Correct | 1045 ms | 4076 KB | Output is correct |
24 | Correct | 1042 ms | 4076 KB | Output is correct |
25 | Correct | 1045 ms | 3948 KB | Output is correct |
26 | Correct | 1022 ms | 3948 KB | Output is correct |
27 | Correct | 1039 ms | 3948 KB | Output is correct |
28 | Correct | 1022 ms | 3948 KB | Output is correct |
29 | Correct | 1020 ms | 3948 KB | Output is correct |
30 | Correct | 1148 ms | 4460 KB | Output is correct |
31 | Correct | 1151 ms | 4460 KB | Output is correct |
32 | Correct | 1145 ms | 4460 KB | Output is correct |
33 | Correct | 1159 ms | 4460 KB | Output is correct |
34 | Correct | 1143 ms | 4460 KB | Output is correct |
35 | Correct | 1148 ms | 4344 KB | Output is correct |
36 | Correct | 1145 ms | 4460 KB | Output is correct |
37 | Correct | 1143 ms | 4460 KB | Output is correct |
38 | Correct | 1148 ms | 4460 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 1132 KB | Output is correct |
2 | Correct | 12 ms | 1132 KB | Output is correct |
3 | Correct | 12 ms | 1132 KB | Output is correct |
4 | Correct | 12 ms | 1132 KB | Output is correct |
5 | Correct | 12 ms | 1132 KB | Output is correct |
6 | Correct | 13 ms | 1132 KB | Output is correct |
7 | Correct | 14 ms | 1260 KB | Output is correct |
8 | Correct | 13 ms | 1132 KB | Output is correct |
9 | Correct | 13 ms | 1132 KB | Output is correct |
10 | Correct | 13 ms | 1132 KB | Output is correct |
11 | Correct | 13 ms | 1132 KB | Output is correct |
12 | Correct | 13 ms | 1132 KB | Output is correct |
13 | Correct | 12 ms | 1132 KB | Output is correct |
14 | Correct | 12 ms | 1132 KB | Output is correct |
15 | Correct | 12 ms | 1132 KB | Output is correct |
16 | Correct | 7 ms | 748 KB | Output is correct |
17 | Correct | 7 ms | 748 KB | Output is correct |
18 | Correct | 7 ms | 748 KB | Output is correct |
19 | Correct | 7 ms | 748 KB | Output is correct |
20 | Correct | 7 ms | 748 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1149 ms | 4356 KB | Output is correct |
2 | Correct | 1153 ms | 4332 KB | Output is correct |
3 | Correct | 1153 ms | 4352 KB | Output is correct |
4 | Correct | 1154 ms | 4356 KB | Output is correct |
5 | Correct | 1152 ms | 4460 KB | Output is correct |
6 | Correct | 1151 ms | 4460 KB | Output is correct |
7 | Correct | 1161 ms | 4356 KB | Output is correct |
8 | Correct | 1164 ms | 4480 KB | Output is correct |
9 | Correct | 1190 ms | 4460 KB | Output is correct |
10 | Correct | 1153 ms | 4352 KB | Output is correct |
11 | Correct | 1148 ms | 4460 KB | Output is correct |
12 | Correct | 1153 ms | 4460 KB | Output is correct |
13 | Correct | 1157 ms | 4460 KB | Output is correct |
14 | Correct | 1170 ms | 4356 KB | Output is correct |
15 | Correct | 1157 ms | 4332 KB | Output is correct |
16 | Correct | 208 ms | 1004 KB | Output is correct |
17 | Correct | 220 ms | 1260 KB | Output is correct |
18 | Correct | 211 ms | 1132 KB | Output is correct |
19 | Correct | 220 ms | 1132 KB | Output is correct |
20 | Correct | 212 ms | 1132 KB | Output is correct |
21 | Correct | 1059 ms | 3948 KB | Output is correct |
22 | Correct | 1073 ms | 4076 KB | Output is correct |
23 | Correct | 1045 ms | 4076 KB | Output is correct |
24 | Correct | 1042 ms | 4076 KB | Output is correct |
25 | Correct | 1045 ms | 3948 KB | Output is correct |
26 | Correct | 1022 ms | 3948 KB | Output is correct |
27 | Correct | 1039 ms | 3948 KB | Output is correct |
28 | Correct | 1022 ms | 3948 KB | Output is correct |
29 | Correct | 1020 ms | 3948 KB | Output is correct |
30 | Correct | 1148 ms | 4460 KB | Output is correct |
31 | Correct | 1151 ms | 4460 KB | Output is correct |
32 | Correct | 1145 ms | 4460 KB | Output is correct |
33 | Correct | 1159 ms | 4460 KB | Output is correct |
34 | Correct | 1143 ms | 4460 KB | Output is correct |
35 | Correct | 1148 ms | 4344 KB | Output is correct |
36 | Correct | 1145 ms | 4460 KB | Output is correct |
37 | Correct | 1143 ms | 4460 KB | Output is correct |
38 | Correct | 1148 ms | 4460 KB | Output is correct |
39 | Correct | 12 ms | 1132 KB | Output is correct |
40 | Correct | 12 ms | 1132 KB | Output is correct |
41 | Correct | 12 ms | 1132 KB | Output is correct |
42 | Correct | 12 ms | 1132 KB | Output is correct |
43 | Correct | 12 ms | 1132 KB | Output is correct |
44 | Correct | 13 ms | 1132 KB | Output is correct |
45 | Correct | 14 ms | 1260 KB | Output is correct |
46 | Correct | 13 ms | 1132 KB | Output is correct |
47 | Correct | 13 ms | 1132 KB | Output is correct |
48 | Correct | 13 ms | 1132 KB | Output is correct |
49 | Correct | 13 ms | 1132 KB | Output is correct |
50 | Correct | 13 ms | 1132 KB | Output is correct |
51 | Correct | 12 ms | 1132 KB | Output is correct |
52 | Correct | 12 ms | 1132 KB | Output is correct |
53 | Correct | 12 ms | 1132 KB | Output is correct |
54 | Correct | 7 ms | 748 KB | Output is correct |
55 | Correct | 7 ms | 748 KB | Output is correct |
56 | Correct | 7 ms | 748 KB | Output is correct |
57 | Correct | 7 ms | 748 KB | Output is correct |
58 | Correct | 7 ms | 748 KB | Output is correct |
59 | Correct | 1358 ms | 4356 KB | Output is correct |
60 | Correct | 1350 ms | 4460 KB | Output is correct |
61 | Correct | 1335 ms | 4460 KB | Output is correct |
62 | Correct | 1354 ms | 4460 KB | Output is correct |
63 | Correct | 1351 ms | 4356 KB | Output is correct |
64 | Correct | 1442 ms | 4460 KB | Output is correct |
65 | Correct | 1449 ms | 4460 KB | Output is correct |
66 | Correct | 1451 ms | 4460 KB | Output is correct |
67 | Correct | 1447 ms | 4460 KB | Output is correct |
68 | Correct | 1444 ms | 4332 KB | Output is correct |
69 | Correct | 1301 ms | 4356 KB | Output is correct |
70 | Correct | 1298 ms | 4460 KB | Output is correct |
71 | Correct | 1308 ms | 4460 KB | Output is correct |
72 | Correct | 1322 ms | 4332 KB | Output is correct |
73 | Correct | 1328 ms | 4460 KB | Output is correct |
74 | Correct | 230 ms | 1132 KB | Output is correct |
75 | Correct | 236 ms | 1260 KB | Output is correct |
76 | Correct | 232 ms | 1132 KB | Output is correct |
77 | Correct | 230 ms | 1132 KB | Output is correct |
78 | Correct | 230 ms | 1132 KB | Output is correct |