# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
509062 | 2022-01-14T02:46:46 Z | ITO | Group Photo (JOI21_ho_t3) | C++11 | 552 ms | 165260 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int fr[5001][5001], pa[5001][5001]; int main() { int n, a[5001], h, b[5001], x = 0, y, c = 0; cin >> n; for (int i = 1; i <= n; i++) { cin >> h; a[h] = i; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { fr[i][j] = fr[i][j - 1]; if (a[j] < a[i]) { fr[i][j]++; } } } for (int i = 1; i <= n; i++) { pa[i][i] = fr[i][n] - fr[i][i]; for (int j = i + 1; j <= n; j++) { pa[i][j] = pa[i][j - 1] + fr[j][n] - fr[j][j] - (j - i) + (fr[j][j] - fr[j][i - 1]) * 2; } } for (int i = n; i > 0; i--) { for (int j = i; j < n; j++) { pa[i][n] = min(pa[i][n], pa[i][j] + pa[j + 1][n]); } } cout << pa[1][n] << '\n'; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 296 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 312 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 316 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 0 ms | 308 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 296 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 312 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 316 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 0 ms | 308 KB | Output is correct |
11 | Correct | 1 ms | 444 KB | Output is correct |
12 | Correct | 1 ms | 460 KB | Output is correct |
13 | Correct | 1 ms | 444 KB | Output is correct |
14 | Correct | 1 ms | 460 KB | Output is correct |
15 | Correct | 0 ms | 460 KB | Output is correct |
16 | Correct | 1 ms | 460 KB | Output is correct |
17 | Correct | 0 ms | 460 KB | Output is correct |
18 | Correct | 0 ms | 460 KB | Output is correct |
19 | Correct | 1 ms | 460 KB | Output is correct |
20 | Correct | 1 ms | 460 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 296 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 312 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 316 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 0 ms | 308 KB | Output is correct |
11 | Correct | 1 ms | 444 KB | Output is correct |
12 | Correct | 1 ms | 460 KB | Output is correct |
13 | Correct | 1 ms | 444 KB | Output is correct |
14 | Correct | 1 ms | 460 KB | Output is correct |
15 | Correct | 0 ms | 460 KB | Output is correct |
16 | Correct | 1 ms | 460 KB | Output is correct |
17 | Correct | 0 ms | 460 KB | Output is correct |
18 | Correct | 0 ms | 460 KB | Output is correct |
19 | Correct | 1 ms | 460 KB | Output is correct |
20 | Correct | 1 ms | 460 KB | Output is correct |
21 | Correct | 1 ms | 2124 KB | Output is correct |
22 | Correct | 2 ms | 2124 KB | Output is correct |
23 | Correct | 2 ms | 2124 KB | Output is correct |
24 | Correct | 1 ms | 2124 KB | Output is correct |
25 | Correct | 1 ms | 2124 KB | Output is correct |
26 | Correct | 1 ms | 2124 KB | Output is correct |
27 | Correct | 2 ms | 2108 KB | Output is correct |
28 | Correct | 2 ms | 2124 KB | Output is correct |
29 | Correct | 3 ms | 2096 KB | Output is correct |
30 | Correct | 2 ms | 2124 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 296 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 312 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 316 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 0 ms | 308 KB | Output is correct |
11 | Correct | 1 ms | 444 KB | Output is correct |
12 | Correct | 1 ms | 460 KB | Output is correct |
13 | Correct | 1 ms | 444 KB | Output is correct |
14 | Correct | 1 ms | 460 KB | Output is correct |
15 | Correct | 0 ms | 460 KB | Output is correct |
16 | Correct | 1 ms | 460 KB | Output is correct |
17 | Correct | 0 ms | 460 KB | Output is correct |
18 | Correct | 0 ms | 460 KB | Output is correct |
19 | Correct | 1 ms | 460 KB | Output is correct |
20 | Correct | 1 ms | 460 KB | Output is correct |
21 | Correct | 1 ms | 2124 KB | Output is correct |
22 | Correct | 2 ms | 2124 KB | Output is correct |
23 | Correct | 2 ms | 2124 KB | Output is correct |
24 | Correct | 1 ms | 2124 KB | Output is correct |
25 | Correct | 1 ms | 2124 KB | Output is correct |
26 | Correct | 1 ms | 2124 KB | Output is correct |
27 | Correct | 2 ms | 2108 KB | Output is correct |
28 | Correct | 2 ms | 2124 KB | Output is correct |
29 | Correct | 3 ms | 2096 KB | Output is correct |
30 | Correct | 2 ms | 2124 KB | Output is correct |
31 | Correct | 8 ms | 10416 KB | Output is correct |
32 | Correct | 8 ms | 10408 KB | Output is correct |
33 | Correct | 9 ms | 10444 KB | Output is correct |
34 | Correct | 9 ms | 10464 KB | Output is correct |
35 | Correct | 8 ms | 10444 KB | Output is correct |
36 | Correct | 8 ms | 10420 KB | Output is correct |
37 | Correct | 8 ms | 10532 KB | Output is correct |
38 | Correct | 13 ms | 10428 KB | Output is correct |
39 | Correct | 8 ms | 10524 KB | Output is correct |
40 | Correct | 8 ms | 10444 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 296 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 312 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 316 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 0 ms | 308 KB | Output is correct |
11 | Correct | 1 ms | 444 KB | Output is correct |
12 | Correct | 1 ms | 460 KB | Output is correct |
13 | Correct | 1 ms | 444 KB | Output is correct |
14 | Correct | 1 ms | 460 KB | Output is correct |
15 | Correct | 0 ms | 460 KB | Output is correct |
16 | Correct | 1 ms | 460 KB | Output is correct |
17 | Correct | 0 ms | 460 KB | Output is correct |
18 | Correct | 0 ms | 460 KB | Output is correct |
19 | Correct | 1 ms | 460 KB | Output is correct |
20 | Correct | 1 ms | 460 KB | Output is correct |
21 | Correct | 1 ms | 2124 KB | Output is correct |
22 | Correct | 2 ms | 2124 KB | Output is correct |
23 | Correct | 2 ms | 2124 KB | Output is correct |
24 | Correct | 1 ms | 2124 KB | Output is correct |
25 | Correct | 1 ms | 2124 KB | Output is correct |
26 | Correct | 1 ms | 2124 KB | Output is correct |
27 | Correct | 2 ms | 2108 KB | Output is correct |
28 | Correct | 2 ms | 2124 KB | Output is correct |
29 | Correct | 3 ms | 2096 KB | Output is correct |
30 | Correct | 2 ms | 2124 KB | Output is correct |
31 | Correct | 8 ms | 10416 KB | Output is correct |
32 | Correct | 8 ms | 10408 KB | Output is correct |
33 | Correct | 9 ms | 10444 KB | Output is correct |
34 | Correct | 9 ms | 10464 KB | Output is correct |
35 | Correct | 8 ms | 10444 KB | Output is correct |
36 | Correct | 8 ms | 10420 KB | Output is correct |
37 | Correct | 8 ms | 10532 KB | Output is correct |
38 | Correct | 13 ms | 10428 KB | Output is correct |
39 | Correct | 8 ms | 10524 KB | Output is correct |
40 | Correct | 8 ms | 10444 KB | Output is correct |
41 | Correct | 461 ms | 165024 KB | Output is correct |
42 | Correct | 459 ms | 165032 KB | Output is correct |
43 | Correct | 534 ms | 165012 KB | Output is correct |
44 | Correct | 552 ms | 165032 KB | Output is correct |
45 | Correct | 542 ms | 165128 KB | Output is correct |
46 | Correct | 529 ms | 165260 KB | Output is correct |
47 | Correct | 459 ms | 165140 KB | Output is correct |
48 | Correct | 441 ms | 165176 KB | Output is correct |
49 | Correct | 448 ms | 165052 KB | Output is correct |
50 | Correct | 439 ms | 165176 KB | Output is correct |
51 | Correct | 450 ms | 165060 KB | Output is correct |
52 | Correct | 433 ms | 165080 KB | Output is correct |
53 | Correct | 438 ms | 165044 KB | Output is correct |
54 | Correct | 431 ms | 165072 KB | Output is correct |
55 | Correct | 457 ms | 165236 KB | Output is correct |