Submission #1369710
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define int long long #define inf 1000000007LL #define mod 1000000007LL #define rep(i, n) for(int i = 0; i < (n); i++) #define trep(i, n) for(int i = 0; i <= (n); i++) #define rrep(i, n) for(int i = (n) - 1; i >= 0; i--) #define rep1(i, n) for(int i = 1; i <= (n); i++) #define mfor(i, s, t) for(int i = (s); i < (t); i++) #define tfor(i, s, t) for(int i = (s); i <= (t); i++) #define rfor(i, s, t) for(int i = (t) - 1; i >= (s); i--) int d[114]; int dp[55][114][114]; signed main() { int n; cin >> n; rep(i, 2 * n - 1) { cin >> d[i]; } sort(d, d + 2 * n - 1); rep(i, n) { rep(j, 2 * n) { rep(k, 2 * n) { dp[i][j][k] = 0; } } } dp[0][1][0] = 1; rep(i, n - 1) { int p, a; if(d[n - 1 - i] == d[n - 1 - i - 1]) { p = 0; } else { p = 1; } if(d[n - 1 + i] == d[n - 1 + i + 1]) { a = 0; } else { a = 1; } rep1(j, i * 2 + 1) { rep(k, j) { rep(_, j + p + a) { if(_ < k + p) { dp[i + 1][j + p + a - ((k + p) - _ - 1)][_] = (dp[i + 1][j + p + a - ((k + p) - _ - 1)][_] + dp[i][j][k]) % inf; } else if(_ == k + p) { dp[i + 1][j + p + a][_] = (dp[i + 1][j + p + a][_] + dp[i][j][k]) % inf; } else { dp[i + 1][j + p + a - (_ - (k + p) - 1)][k + p + 1] = (dp[i + 1][j + p + a - (_ - (k + p) - 1)][k + p + 1] + dp[i][j][k]) % inf; } } } } } int all = 0; rep(j, 2 * n) { rep(k, 2 * n) { all = (all + dp[n - 1][j][k]) % inf; } } cout << all << endl; }
Submission Info
Submission Time | |
---|---|
Task | F - Prefix Median |
User | goto |
Language | C++14 (GCC 5.4.1) |
Score | 2000 |
Code Size | 1728 Byte |
Status | AC |
Exec Time | 13 ms |
Memory | 5120 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 2000 / 2000 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt |
All | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 1 ms | 256 KB |
00_example_02.txt | AC | 1 ms | 256 KB |
00_example_03.txt | AC | 1 ms | 640 KB |
01.txt | AC | 13 ms | 5120 KB |
02.txt | AC | 10 ms | 4480 KB |
03.txt | AC | 3 ms | 3456 KB |
04.txt | AC | 2 ms | 3200 KB |
05.txt | AC | 2 ms | 896 KB |
06.txt | AC | 6 ms | 3712 KB |
07.txt | AC | 13 ms | 5120 KB |
08.txt | AC | 2 ms | 896 KB |
09.txt | AC | 13 ms | 5120 KB |
10.txt | AC | 1 ms | 384 KB |
11.txt | AC | 1 ms | 512 KB |
12.txt | AC | 2 ms | 768 KB |
13.txt | AC | 5 ms | 3584 KB |
14.txt | AC | 7 ms | 3840 KB |
15.txt | AC | 1 ms | 384 KB |
16.txt | AC | 13 ms | 5120 KB |
17.txt | AC | 1 ms | 512 KB |
18.txt | AC | 1 ms | 256 KB |
19.txt | AC | 1 ms | 256 KB |
20.txt | AC | 1 ms | 640 KB |
21.txt | AC | 1 ms | 640 KB |
22.txt | AC | 1 ms | 256 KB |
23.txt | AC | 3 ms | 3328 KB |
24.txt | AC | 2 ms | 896 KB |
25.txt | AC | 3 ms | 3328 KB |
26.txt | AC | 4 ms | 3456 KB |
27.txt | AC | 2 ms | 768 KB |
28.txt | AC | 11 ms | 4736 KB |
29.txt | AC | 2 ms | 3200 KB |
30.txt | AC | 4 ms | 3456 KB |
31.txt | AC | 1 ms | 256 KB |
32.txt | AC | 3 ms | 3456 KB |
33.txt | AC | 1 ms | 256 KB |
34.txt | AC | 3 ms | 3328 KB |
35.txt | AC | 10 ms | 4480 KB |
36.txt | AC | 1 ms | 256 KB |
37.txt | AC | 10 ms | 4480 KB |
38.txt | AC | 3 ms | 3456 KB |
39.txt | AC | 2 ms | 3200 KB |
40.txt | AC | 2 ms | 896 KB |
41.txt | AC | 6 ms | 3712 KB |
42.txt | AC | 13 ms | 5120 KB |
43.txt | AC | 2 ms | 896 KB |
44.txt | AC | 13 ms | 5120 KB |
45.txt | AC | 1 ms | 384 KB |
46.txt | AC | 1 ms | 512 KB |
47.txt | AC | 2 ms | 768 KB |
48.txt | AC | 5 ms | 3584 KB |
49.txt | AC | 7 ms | 3840 KB |
50.txt | AC | 1 ms | 384 KB |
51.txt | AC | 13 ms | 5120 KB |