用户输出
23
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#101489 | #1432. [L2-1] 树木加固 | Accepted | 100 | 75 ms | 4480 K | C++ 17 (Clang) / 571 B | Veritas | 2024-03-12 14:48:06 |
#include <iostream>
using namespace std;
int read() {
int x = 0, w = 1;
char ch = 0;
while (ch < '0' || ch > '9') {
if (ch == '-')
w = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + (ch - '0');
ch = getchar();
}
return x * w;
}
int a[22][2000006];
int main() {
int n = read(), ans = 0;
for (int i = 0; i < n; ++i)
for (int j = 1; j <= (1 << i); ++j) a[i][j] = read();
for (int i = n - 2; i >= 0; --i)
for (int j = 1; j <= (1 << i); ++j) a[i][j] += a[i + 1][2 * j] + a[i + 1][2 * j - 1];
for (int i = 1; i < n; ++i)
for (int j = 1; j <= (1 << i); ++j) ans += (a[i][j] < 0 ? -a[i][j] : a[i][j]);
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