# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
774788 | 2023-07-06T03:26:34 Z | RecursiveCo | Group Photo (JOI21_ho_t3) | C++14 | 5000 ms | 4052 KB |
// CF template, version 3.0 #include <bits/stdc++.h> using namespace std; #define improvePerformance ios_base::sync_with_stdio(false); cin.tie(0) #define getTest int t; cin >> t #define eachTest for (int _var=0;_var<t;_var++) #define get(name) int (name); cin >> (name) #define out(o) cout << (o) #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); } #define sortl(name) sort((name).begin(), (name).end()) #define rev(name) reverse((name).begin(), (name).end()) #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++) #define decision(b) if (b){out("YES");}else{out("NO");} #define int long long int signed main() { improvePerformance; get(n); getList(n, nums); forto(n, i) nums[i]--; vector<int> dp(n); vector<vector<int>> inv(n); vector<vector<int>> invinv(n); forto(n, i) { for (int j = i + 1; j < n; j++) { if (nums[i] > nums[j]) inv[nums[j]].push_back(nums[i]); else invinv[nums[i]].push_back(nums[j]); } } forto(n, i) { int el = 1e18; forto(i + 1, s) { int sz = s + 1; int cur = i - sz == -1? 0: dp[i - sz]; int j = i - sz + 1; for (int k = j; k <= i; k++) { for (int num: invinv[k]) { if (num <= i) cur++; } for (int num: inv[k]) { if (i < num) cur++; } } el = min(el, cur); } dp[i] = el; } out(dp[n - 1]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 316 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 316 KB | Output is correct |
5 | Correct | 1 ms | 316 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 316 KB | Output is correct |
10 | Correct | 0 ms | 316 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 316 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 316 KB | Output is correct |
5 | Correct | 1 ms | 316 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 316 KB | Output is correct |
10 | Correct | 0 ms | 316 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 316 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 316 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 324 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 316 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 316 KB | Output is correct |
5 | Correct | 1 ms | 316 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 316 KB | Output is correct |
10 | Correct | 0 ms | 316 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 316 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 316 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 324 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 98 ms | 560 KB | Output is correct |
22 | Correct | 102 ms | 552 KB | Output is correct |
23 | Correct | 108 ms | 556 KB | Output is correct |
24 | Correct | 101 ms | 576 KB | Output is correct |
25 | Correct | 101 ms | 568 KB | Output is correct |
26 | Correct | 101 ms | 568 KB | Output is correct |
27 | Correct | 102 ms | 560 KB | Output is correct |
28 | Correct | 108 ms | 572 KB | Output is correct |
29 | Correct | 101 ms | 560 KB | Output is correct |
30 | Correct | 103 ms | 556 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 316 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 316 KB | Output is correct |
5 | Correct | 1 ms | 316 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 316 KB | Output is correct |
10 | Correct | 0 ms | 316 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 316 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 316 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 324 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 98 ms | 560 KB | Output is correct |
22 | Correct | 102 ms | 552 KB | Output is correct |
23 | Correct | 108 ms | 556 KB | Output is correct |
24 | Correct | 101 ms | 576 KB | Output is correct |
25 | Correct | 101 ms | 568 KB | Output is correct |
26 | Correct | 101 ms | 568 KB | Output is correct |
27 | Correct | 102 ms | 560 KB | Output is correct |
28 | Correct | 108 ms | 572 KB | Output is correct |
29 | Correct | 101 ms | 560 KB | Output is correct |
30 | Correct | 103 ms | 556 KB | Output is correct |
31 | Execution timed out | 5059 ms | 4052 KB | Time limit exceeded |
32 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 316 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 316 KB | Output is correct |
5 | Correct | 1 ms | 316 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 316 KB | Output is correct |
10 | Correct | 0 ms | 316 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 316 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 316 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 324 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 98 ms | 560 KB | Output is correct |
22 | Correct | 102 ms | 552 KB | Output is correct |
23 | Correct | 108 ms | 556 KB | Output is correct |
24 | Correct | 101 ms | 576 KB | Output is correct |
25 | Correct | 101 ms | 568 KB | Output is correct |
26 | Correct | 101 ms | 568 KB | Output is correct |
27 | Correct | 102 ms | 560 KB | Output is correct |
28 | Correct | 108 ms | 572 KB | Output is correct |
29 | Correct | 101 ms | 560 KB | Output is correct |
30 | Correct | 103 ms | 556 KB | Output is correct |
31 | Execution timed out | 5059 ms | 4052 KB | Time limit exceeded |
32 | Halted | 0 ms | 0 KB | - |