-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path10337.cpp
More file actions
40 lines (32 loc) · 963 Bytes
/
10337.cpp
File metadata and controls
40 lines (32 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
using namespace std;
int tc, len, winds[12][12], dp[12][12];
int main() {
cin >> tc;
while (tc--) {
cin >> len;
for (int i = 9; i >= 0; i--)
for (int j = 0; j < len/100; j++)
cin >> winds[i][j];
for (int i = 0; i <= 10; i++)
for (int j = 0; j <= len/100; j++)
dp[i][j] = 100000;
for (int j = 1; j <= 10; j++)
winds[0][j] = -100000;
dp[0][0] = 0;
for (int j = 0; j <= len/100; j++)
for (int i = 0; i < 10; i++) {
if (i > 0) dp[i-1][j+1] = min(dp[i-1][j+1], dp[i][j] + 20 - winds[i][j]);
dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + 60 - winds[i][j]);
dp[i][j+1] = min(dp[i][j+1], dp[i][j] + 30 - winds[i][j]);
}
for (int i = 0; i < 10; i++) {
for (int j = 0; j < len/100; j++)
cout << dp[i][j] << ' ';
cout << endl;
} cout << endl;
cout << dp[0][len/100]<< endl;
if (tc) cout << endl;
}
return 0;
}