Submission #871022

# Submission time Handle Problem Language Result Execution time Memory
871022 2023-11-09T17:42:36 Z Trisanu_Das Giraffes (JOI22_giraffes) C++17
59 / 100
58 ms 109396 KB
#include<bits/stdc++.h>
using namespace std;
 
int n, a[400];
int dp[400][400][400];
 
int main(){
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = n; i; i--){
		for (int j = 1; j <= n; j++) dp[i][i][j] = (a[j] != i);
		for (int j = i+1; j <= n; j++) for (int k = 1; k+j-i <= n; k++) dp[i][j][k] = min({dp[i+1][j][k] + (a[k+j-i] != i), dp[i+1][j][k+1] + (a[k] != i)
						, dp[i][j-1][k] + (a[k+j-i] != j), dp[i][j-1][k+1] + (a[k] != j)});
	}
	cout << dp[1][n][1] << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 6592 KB Output is correct
9 Correct 7 ms 6592 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 6592 KB Output is correct
9 Correct 7 ms 6592 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6592 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 1 ms 8540 KB Output is correct
15 Correct 1 ms 8540 KB Output is correct
16 Correct 1 ms 8540 KB Output is correct
17 Correct 1 ms 8540 KB Output is correct
18 Correct 1 ms 8540 KB Output is correct
19 Correct 1 ms 8540 KB Output is correct
20 Correct 1 ms 8536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 6592 KB Output is correct
9 Correct 7 ms 6592 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6592 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 1 ms 8540 KB Output is correct
15 Correct 1 ms 8540 KB Output is correct
16 Correct 1 ms 8540 KB Output is correct
17 Correct 1 ms 8540 KB Output is correct
18 Correct 1 ms 8540 KB Output is correct
19 Correct 1 ms 8540 KB Output is correct
20 Correct 1 ms 8536 KB Output is correct
21 Correct 2 ms 19032 KB Output is correct
22 Correct 7 ms 45492 KB Output is correct
23 Correct 18 ms 63688 KB Output is correct
24 Correct 31 ms 84476 KB Output is correct
25 Correct 45 ms 102864 KB Output is correct
26 Correct 50 ms 106104 KB Output is correct
27 Correct 49 ms 106424 KB Output is correct
28 Correct 58 ms 106968 KB Output is correct
29 Correct 49 ms 107344 KB Output is correct
30 Correct 50 ms 109396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 6592 KB Output is correct
9 Correct 7 ms 6592 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6592 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 1 ms 8540 KB Output is correct
15 Correct 1 ms 8540 KB Output is correct
16 Correct 1 ms 8540 KB Output is correct
17 Correct 1 ms 8540 KB Output is correct
18 Correct 1 ms 8540 KB Output is correct
19 Correct 1 ms 8540 KB Output is correct
20 Correct 1 ms 8536 KB Output is correct
21 Correct 2 ms 19032 KB Output is correct
22 Correct 7 ms 45492 KB Output is correct
23 Correct 18 ms 63688 KB Output is correct
24 Correct 31 ms 84476 KB Output is correct
25 Correct 45 ms 102864 KB Output is correct
26 Correct 50 ms 106104 KB Output is correct
27 Correct 49 ms 106424 KB Output is correct
28 Correct 58 ms 106968 KB Output is correct
29 Correct 49 ms 107344 KB Output is correct
30 Correct 50 ms 109396 KB Output is correct
31 Runtime error 5 ms 348 KB Execution killed with signal 11
32 Halted 0 ms 0 KB -