用户输出
23
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#102017 | #1432. [L2-1] 树木加固 | Accepted | 100 | 516 ms | 12880 K | C++ 11 / 451 B | hwpvector | 2024-03-16 21:38:49 |
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<int> v[30];
signed main(void) {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
v[i].push_back(0);
for (int j = 1; j <= (1 << (i - 1)); j++) {
int x;
cin >> x;
v[i].push_back(x);
}
}
v[0].push_back(0);
int ans = 0;
for (int i = n; i >= 1; i--) {
for (int j = 1; j <= (1 << (i - 1)); j++) ans += abs(v[i][j]), v[i - 1][(j + 1) / 2] += v[i][j];
// cout<<ans<<endl;
}
cout << ans;
}
用户输出
11887
系统信息
Exited with return code 0
用户输出
8158
系统信息
Exited with return code 0
8
114
-808 -998
-826 -984 316 9
-510 -266 401 -830 860 388 -560 -918
67 -319 -972 -451 -30 267 -
<1036 bytes omitted>
用户输出
272319
系统信息
Exited with return code 0
8
-822
-975 757
984 -999 989 -284
81 981 -308 998 -596 395 -673 -738
889 -780 -353 448 -788 -492
<1037 bytes omitted>
用户输出
255014
系统信息
Exited with return code 0
8
-646
-115 -20
-448 712 -920 618
-28 -977 317 160 -621 970 -994 -326
-738 446 -103 -190 218 958
<1037 bytes omitted>
用户输出
273545
系统信息
Exited with return code 0
8
-26
-528 -860
-580 687 -902 680
-997 -939 858 -150 43 977 -605 813
-732 128 28 -68 693 -525 31
<1035 bytes omitted>
用户输出
259605
系统信息
Exited with return code 0
20
53
-291 14
-319 278 -699 -876
-867 947 653 -677 138 359 -47 -702
-112 341 -445 -435 -312 -450
<2176336 bytes omitted>
用户输出
37703792
系统信息
Exited with return code 0
20
-654
-404 -914
-142 819 -993 -963
42 -707 292 -964 -857 408 -33 -731
-877 -2 515 206 877 952
<2176313 bytes omitted>
用户输出
38042269
系统信息
Exited with return code 0