-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1.cpp
More file actions
53 lines (41 loc) · 1.01 KB
/
Copy path1.cpp
File metadata and controls
53 lines (41 loc) · 1.01 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <bits/stdc++.h>
using namespace std;
int T, K;
vector<int> input;
int dp[501][501];
int sum[501][501];
void sol(){
//sum 계산
for(int i = 1; i <= K; i++){
sum[i][i] = input[i];
for(int j = i + 1; j <= K; j++){
sum[i][j] = sum[i][j - 1] + input[j];
}
}
cout << sum[0][K];
// for(int len = 1; len < K; len++){
// for(int j = 1; len + j <= K; j++){
// dp[j][len + j] = INT_MAX;
// for(int mid = j; mid < len + j; mid++){
// dp[j][len + j] = min(dp[j][len + j],
// dp[j][mid] + dp[mid + 1][len + j] + sum[j][len + j]);
// }
// }
// }
}
int main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> T;
for(int i = 0; i < T; i++){
cin >> K;
int num;
for(int i = 0; i < K; i++){
cin >> num;
input.push_back(num);
}
sol();
input.clear();
}
sol();
return 0;
}