QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#112223 | #674. Ascending Tree | yHas | AC ✓ | 41ms | 24340kb | C++14 | 1.5kb | 2023-06-10 19:26:23 | 2023-06-10 19:26:26 |
Judging History
answer
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define LL long long
using namespace std;
#define L(i, s, t) for(int i = s; i <= t; ++i)
#define R(i, t, s) for(int i = t; i >= s; --i)
void read(int &x) {
x = 0; int w = 1; char c = getchar(); for(; c < '0' || c > '9'; c = getchar()) if (c == '-') w = -1;
for(; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + c - '0'; x *= w;
}
const int N = 1e5;
int n, fa[N + 5], c[N + 5], dep[N + 5], sz[N + 5];
int h[N + 5], nxt[2 * N + 5], e[2 * N + 5];
priority_queue<int > q[N + 5]; LL ans;
void dfs(int x, int ff) {
q[x].push(c[x]); sz[x] = 1;
int son = -1;
for(int i = h[x]; i; i = nxt[i]) {
int v = e[i];
if (v == ff) continue;
dfs(v, x);
if (son == -1 || sz[v] > sz[son])
son = v;
sz[x] += sz[v];
}
if (son != -1) swap(q[x], q[son]);
for(int i = h[x]; i; i = nxt[i]) {
int v = e[i];
if (v == ff) continue;
while(!q[v].empty()) {q[x].push(q[v].top()); q[v].pop();}
}
// if (x == 3) cout << c[x] << ' ' << q[x].top() << endl;
if (c[x] < q[x].top()) {
ans += q[x].top() - c[x];
q[x].pop();
q[x].push(c[x]);
}
// q[x].push(c[x]);
}
int tot;
void add(int x, int y) {nxt[++tot] = h[x]; e[tot] = y; h[x] = tot;}
int main() {
// freopen("t.in", "r", stdin);
// q[1].pop();
read(n); read(c[1]);
for(int i = 2; i <= n; ++i)
{read(fa[i]); dep[i] = dep[fa[i]] + 1; read(c[i]); c[i] += dep[i];
add(i, fa[i]); add(fa[i], i);
}
dfs(1, 0);
printf("%lld\n", ans);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 9512kb
input:
21 -28 1 -21 2 -7 3 -3 4 -44 4 21 4 -39 4 42 2 -49 9 16 8 -22 5 -49 11 -8 1 3 11 28 3 8 8 -38 16 34 4 -45 7 -43 2 7
output:
290
result:
ok single line: '290'
Test #2:
score: 0
Accepted
time: 4ms
memory: 9464kb
input:
1 46
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 3ms
memory: 9832kb
input:
17 6 1 -26 1 -50 3 -3 1 -27 4 -36 2 -14 5 -37 4 -50 3 -15 6 -25 10 -39 6 4 11 17 11 10 13 26 1 -42
output:
193
result:
ok single line: '193'
Test #4:
score: 0
Accepted
time: 0ms
memory: 9332kb
input:
47 1 1 -50 2 36 3 43 1 15 2 -32 2 -7 2 30 4 33 9 -35 9 -29 9 -35 2 -36 6 -28 11 10 7 46 6 12 15 -3 7 22 1 28 2 -42 2 43 13 12 6 1 9 42 14 -12 21 -12 26 -5 22 13 3 44 10 18 31 27 1 -33 6 -47 11 -28 21 -40 11 -31 19 -47 37 -1 21 -16 25 15 27 -49 1 14 19 34 8 24 5 16 23 42
output:
543
result:
ok single line: '543'
Test #5:
score: 0
Accepted
time: 0ms
memory: 10124kb
input:
2 4 1 -8
output:
0
result:
ok single line: '0'
Test #6:
score: 0
Accepted
time: 2ms
memory: 10024kb
input:
50 -24 1 12 1 -43 3 15 3 -6 5 -42 1 11 1 -36 2 -17 7 40 6 -30 7 30 2 -39 10 9 7 42 8 17 1 -39 14 43 3 33 1 -36 20 -15 18 34 1 3 8 19 22 21 22 -38 2 -44 9 2 15 36 5 -7 21 -31 25 40 23 -48 15 30 7 22 27 -40 13 -50 3 -17 14 -14 26 -47 21 -49 41 27 27 -15 18 -17 38 20 44 -5 24 23 43 -8 7 -46 20 25
output:
552
result:
ok single line: '552'
Test #7:
score: 0
Accepted
time: 0ms
memory: 7072kb
input:
17 -18 1 40 1 -42 1 -17 2 3 4 1 2 28 1 -27 2 -15 4 39 8 -47 3 40 1 50 4 -34 3 13 4 25 12 42
output:
212
result:
ok single line: '212'
Test #8:
score: 0
Accepted
time: 1ms
memory: 6980kb
input:
6 -29 1 2 2 -36 3 30 3 25 2 5
output:
128
result:
ok single line: '128'
Test #9:
score: 0
Accepted
time: 4ms
memory: 9976kb
input:
4 -28 1 1 1 44 3 23
output:
73
result:
ok single line: '73'
Test #10:
score: 0
Accepted
time: 4ms
memory: 10072kb
input:
16 -41 1 -29 1 40 1 39 1 35 4 34 3 38 2 -50 1 14 3 24 3 -11 2 45 5 27 3 32 4 -17 4 -2
output:
157
result:
ok single line: '157'
Test #11:
score: 0
Accepted
time: 0ms
memory: 9836kb
input:
22 -12 1 8 2 13 3 8 3 -48 3 -42 4 -39 4 -46 3 -15 7 19 3 16 3 25 12 -18 11 12 5 19 5 11 16 -3 12 -39 11 27 8 24 18 3 6 31
output:
381
result:
ok single line: '381'
Test #12:
score: 0
Accepted
time: 3ms
memory: 7228kb
input:
24 -25 1 -29 2 41 1 -20 3 24 5 -37 1 17 7 28 1 -1 4 50 7 -2 4 29 11 40 1 7 14 33 14 -31 1 44 3 35 12 8 1 16 3 -31 10 10 20 -50 22 -9
output:
294
result:
ok single line: '294'
Test #13:
score: 0
Accepted
time: 3ms
memory: 6832kb
input:
2 23 1 6
output:
0
result:
ok single line: '0'
Test #14:
score: 0
Accepted
time: 4ms
memory: 7104kb
input:
49 1 1 -14 2 48 2 43 2 36 3 -2 2 11 6 41 1 -7 4 -46 7 -48 3 -22 5 -38 9 -31 14 42 15 12 12 36 1 8 6 -27 17 -2 6 42 4 50 8 -26 7 34 10 -26 20 32 20 4 1 -32 13 -18 22 12 19 -40 19 -43 15 0 2 -13 14 27 26 -39 23 1 36 33 9 -30 30 -16 13 8 22 46 37 21 42 46 5 41 6 -30 2 2 3 -6 4 -42
output:
590
result:
ok single line: '590'
Test #15:
score: 0
Accepted
time: 3ms
memory: 10204kb
input:
24 27 1 -17 1 39 1 38 3 21 1 -22 1 -37 1 0 2 15 7 23 9 -45 5 -43 12 -28 13 30 13 14 1 -6 11 -45 13 -34 15 22 8 -28 9 -46 6 -22 1 -3 17 0
output:
282
result:
ok single line: '282'
Test #16:
score: 0
Accepted
time: 3ms
memory: 7120kb
input:
30 -6 1 -14 2 0 3 -2 1 3 4 10 2 47 6 31 7 9 7 33 9 -47 6 -4 2 17 10 -35 4 32 4 -43 4 50 2 -6 7 -21 19 4 20 -9 20 -19 1 -49 9 31 22 -31 3 -15 14 47 25 -40 10 -40 7 0
output:
345
result:
ok single line: '345'
Test #17:
score: 0
Accepted
time: 0ms
memory: 8188kb
input:
16 39 1 46 1 -37 1 -9 3 15 3 -19 5 -27 6 11 1 -38 5 14 10 -3 11 33 4 46 8 -29 11 -33 5 -47
output:
185
result:
ok single line: '185'
Test #18:
score: 0
Accepted
time: 3ms
memory: 7380kb
input:
33 34 1 24 1 17 2 46 1 -32 4 47 5 24 4 40 7 40 3 -16 8 -44 6 29 10 -37 13 34 8 -14 6 50 12 -15 12 -49 6 7 1 40 3 -5 8 45 1 -23 20 45 20 -2 17 -11 7 29 2 27 7 44 25 50 26 0 11 36 28 23
output:
375
result:
ok single line: '375'
Test #19:
score: 0
Accepted
time: 3ms
memory: 8364kb
input:
14 13 1 -6 2 49 1 8 1 36 1 -23 5 18 6 41 3 -41 1 -43 3 39 4 39 1 45 2 -47
output:
186
result:
ok single line: '186'
Test #20:
score: 0
Accepted
time: 3ms
memory: 8732kb
input:
18 -43 1 -4 2 32 2 15 2 -47 3 -42 3 33 3 43 5 -23 9 30 5 2 1 -31 2 -3 12 12 5 46 3 31 14 3 12 -4
output:
320
result:
ok single line: '320'
Test #21:
score: 0
Accepted
time: 3ms
memory: 10088kb
input:
21 10 1 3 1 41 3 14 4 5 5 -35 3 30 5 -5 2 -23 4 31 3 -14 8 -18 12 -19 12 35 1 48 2 50 9 -38 10 -24 3 28 16 10 19 38
output:
170
result:
ok single line: '170'
Test #22:
score: 0
Accepted
time: 3ms
memory: 7328kb
input:
12 20 1 12 2 10 2 -3 1 7 1 6 4 -38 5 33 6 -36 5 9 4 17 2 29
output:
66
result:
ok single line: '66'
Test #23:
score: 0
Accepted
time: 3ms
memory: 8504kb
input:
18 29 1 -13 2 -42 2 16 1 47 5 -42 2 -15 4 21 1 -5 4 7 2 20 10 -17 9 38 3 -22 7 -15 1 35 16 -34 2 -31
output:
125
result:
ok single line: '125'
Test #24:
score: 0
Accepted
time: 0ms
memory: 10144kb
input:
27 29 1 -40 1 9 2 -43 1 33 1 -40 2 44 1 5 7 -20 1 -27 3 13 2 -4 8 -29 10 26 8 32 6 -45 3 -22 12 -45 6 -10 13 -27 10 37 21 -31 17 -48 10 -40 11 5 17 43 6 -16
output:
288
result:
ok single line: '288'
Test #25:
score: 0
Accepted
time: 3ms
memory: 8564kb
input:
41 -38 1 -39 1 47 2 -3 4 42 1 18 1 24 6 22 3 -5 3 -27 4 -5 10 -24 3 -23 4 4 4 23 14 36 2 48 1 -2 13 44 16 21 10 -25 15 -7 8 15 7 -20 17 -11 7 25 5 39 6 29 24 -8 26 -10 10 7 22 44 17 1 7 43 2 0 31 -40 33 14 25 29 2 15 22 26 21 40
output:
579
result:
ok single line: '579'
Test #26:
score: 0
Accepted
time: 0ms
memory: 8720kb
input:
33 34 1 23 2 -8 1 -30 2 -33 2 31 1 -26 1 4 2 36 7 0 8 10 3 15 6 50 3 41 12 26 1 42 15 17 13 -21 5 -22 7 42 16 -40 20 -27 12 -19 8 -5 6 45 8 11 19 40 12 -44 16 -36 19 31 15 35 11 47 26 46
output:
405
result:
ok single line: '405'
Test #27:
score: 0
Accepted
time: 1ms
memory: 9592kb
input:
3 -5 1 48 2 26
output:
54
result:
ok single line: '54'
Test #28:
score: 0
Accepted
time: 1ms
memory: 6716kb
input:
4 -21 1 35 1 15 2 48
output:
71
result:
ok single line: '71'
Test #29:
score: 0
Accepted
time: 3ms
memory: 8300kb
input:
1 39
output:
0
result:
ok single line: '0'
Test #30:
score: 0
Accepted
time: 3ms
memory: 9952kb
input:
11 23 1 -23 2 -47 3 -11 4 5 3 8 6 -21 6 25 6 33 9 -18 10 2
output:
171
result:
ok single line: '171'
Test #31:
score: 0
Accepted
time: 0ms
memory: 8368kb
input:
69 43636113 1 5405702 2 727818255 2 215703886 2 556282065 3 801493612 1 -733902850 5 -3315121 3 11086272 5 89837998 5 -761298502 1 -231117599 12 -494408851 11 -252522259 6 242716160 12 -587566106 1 762258393 2 -342982764 6 -170405396 17 679701611 4 -383771573 16 144432809 12 -383745376 3 679048013 9...
output:
10645730240
result:
ok single line: '10645730240'
Test #32:
score: 0
Accepted
time: 0ms
memory: 10172kb
input:
47 -463978011 1 -733517120 2 -706209784 1 -137140149 2 -814588305 3 887716152 4 -401995946 1 300970682 5 180495578 4 -168706299 9 529405865 11 370619462 12 160342473 8 838347752 14 -84206910 11 -458570474 10 294653294 3 201275316 2 -45871334 10 734616864 18 85271905 15 -72563272 18 -320711082 3 -547...
output:
9817966623
result:
ok single line: '9817966623'
Test #33:
score: 0
Accepted
time: 0ms
memory: 8712kb
input:
67 -535075112 1 -384915859 2 -14243300 3 980608684 3 634554908 2 -115725761 6 -439860812 3 698899582 7 368916917 7 -12458332 10 -217381733 9 -963864479 7 133346254 7 389209294 12 -246160129 11 359293721 4 -166548427 11 390931567 10 954377409 19 -1726408 16 -892266630 19 -453542045 21 390189855 13 55...
output:
15525427714
result:
ok single line: '15525427714'
Test #34:
score: 0
Accepted
time: 3ms
memory: 7052kb
input:
43 95112362 1 -380129772 1 -592564105 3 599845290 2 -231192960 4 -250733367 2 847760916 4 491811659 5 -249797358 4 -125549324 9 -58948555 8 -390370365 12 627329303 4 -284623858 3 822244049 11 786017192 5 -286040597 17 -216069727 16 -769864863 10 -258931680 1 615402987 13 -417041133 11 355536306 4 -5...
output:
8853607503
result:
ok single line: '8853607503'
Test #35:
score: 0
Accepted
time: 3ms
memory: 7152kb
input:
83 740081551 1 16582466 2 3625682 2 -748166723 3 -212952115 2 931176016 1 -388315710 5 352555909 8 -185746871 5 451489062 6 -277918792 4 497109799 11 295475559 7 47584604 1 -32979003 10 -230513267 10 -224663541 16 -65977905 11 8930862 6 -111769916 11 937572535 18 -140425023 21 146619616 1 618589169 ...
output:
19157023130
result:
ok single line: '19157023130'
Test #36:
score: 0
Accepted
time: 1ms
memory: 10232kb
input:
89 315435389 1 -484998043 2 92157607 2 -463921043 3 471444942 4 585741930 2 475958414 3 497438231 6 -373873569 4 668310021 3 116330836 5 -918353031 1 237998727 11 -774289171 10 -181121124 11 820278602 3 -432160088 4 806737950 2 254404063 4 442693993 1 -67194996 4 -74257594 17 640975765 1 166465793 2...
output:
17649920833
result:
ok single line: '17649920833'
Test #37:
score: 0
Accepted
time: 4ms
memory: 8392kb
input:
86 -534170057 1 109082428 2 54248174 3 -628046283 3 -33963257 5 123608658 5 539121116 4 498008104 4 -15239164 1 -554102165 2 -154100730 1 632812078 9 282529686 7 596318908 8 -398399878 1 371461328 2 969396102 15 -264829694 3 -670826265 5 -37130398 20 -199193867 1 169515197 8 92141801 9 -394889018 24...
output:
19355537032
result:
ok single line: '19355537032'
Test #38:
score: 0
Accepted
time: 1ms
memory: 7128kb
input:
4 -12752425 1 422792907 1 -94783508 2 -279732810
output:
435545333
result:
ok single line: '435545333'
Test #39:
score: 0
Accepted
time: 3ms
memory: 8292kb
input:
94 -884333811 1 66962378 1 322316628 3 509397371 3 63663842 2 399202456 2 -434106632 1 291662786 1 841587143 8 63688811 1 -881180978 6 -948543065 8 -786115874 7 -416554722 13 792309902 13 -638315720 5 90911662 14 484052170 15 484563170 5 459799966 7 -48952614 8 479520659 10 -403369149 1 414075350 12...
output:
21232326856
result:
ok single line: '21232326856'
Test #40:
score: 0
Accepted
time: 1ms
memory: 9804kb
input:
36 -317839369 1 908946685 2 286612160 1 -867694410 2 817153262 5 -851396702 3 -107331307 3 2332437 2 979036878 1 130416907 10 444302197 3 -692817546 3 566404172 12 374483388 7 641965992 3 -799111216 3 4582928 6 -182465156 13 -125138678 6 -46002931 11 933267848 8 -207348827 1 876480647 9 95160421 2 -...
output:
6364295559
result:
ok single line: '6364295559'
Test #41:
score: 0
Accepted
time: 2ms
memory: 6964kb
input:
85 534183843 1 -105753880 2 -888003497 2 710981102 2 -358723889 1 -753034082 4 167631235 6 440946198 7 -132404365 7 101089735 3 -878442092 3 131523657 7 -996048942 3 -214029522 4 -85280915 15 -273751581 14 815706073 10 -612209463 6 964247115 4 -551579942 1 827883616 11 306758307 2 173614611 7 619803...
output:
19840410676
result:
ok single line: '19840410676'
Test #42:
score: 0
Accepted
time: 4ms
memory: 10220kb
input:
17 -88314481 1 -304310559 1 -83905164 3 -36178022 2 -14793213 5 -927858195 2 -104201872 1 -197220078 5 634009181 2 -495928100 5 -296587889 3 -867224796 5 623555601 4 -641963082 9 118222597 12 509686802 12 307259659
output:
3551282063
result:
ok single line: '3551282063'
Test #43:
score: 0
Accepted
time: 1ms
memory: 9804kb
input:
65 899355303 1 -903714765 2 -697022573 3 -395625348 1 -749373270 5 -874036517 3 -259061680 5 -625671062 3 -504251117 9 -840211464 9 -969182540 4 -442011567 10 893763310 4 -129684290 1 -42306094 1 473295307 12 -21821017 9 -127343138 13 402187524 6 -144269509 6 202373062 18 -526666266 16 -770336667 4 ...
output:
20504291521
result:
ok single line: '20504291521'
Test #44:
score: 0
Accepted
time: 0ms
memory: 7060kb
input:
9 -133338635 1 116142656 2 996089903 2 -667162503 1 -692753533 3 -466479409 3 -254665589 3 191998465 8 -62007580
output:
1205284351
result:
ok single line: '1205284351'
Test #45:
score: 0
Accepted
time: 4ms
memory: 9664kb
input:
68 -122685901 1 -55468631 1 69045340 3 673018245 3 -536150228 3 40233660 6 -248334892 2 -513062991 3 -386599581 6 -537393928 7 -206402019 6 -591387934 6 322606132 11 419836388 11 795768870 12 946094676 10 -457517252 8 347347103 14 -654490747 13 -321616818 18 686659179 5 580905433 6 140739016 16 1518...
output:
17070272382
result:
ok single line: '17070272382'
Test #46:
score: 0
Accepted
time: 1ms
memory: 7132kb
input:
91 873632160 1 -293828905 1 321000267 2 -285100690 2 152146368 3 -888664559 4 -582339196 1 -736537504 4 504169568 5 -24825128 7 -617744885 7 866901600 7 -130127532 11 -967932791 6 -810091754 11 -219890047 5 -915103009 12 98009934 13 -848258118 6 165957069 1 -516012203 18 361228404 12 -893900456 2 -4...
output:
22077682826
result:
ok single line: '22077682826'
Test #47:
score: 0
Accepted
time: 4ms
memory: 9928kb
input:
39 124780835 1 570313518 1 581993867 3 16972932 4 -694792741 4 86608238 5 93543660 7 989413664 8 773233846 1 -494790721 1 846813611 11 -366180745 3 -184715124 6 845364266 5 168532124 9 80288734 5 817867963 9 -352476552 3 -720022993 13 26369964 8 -658592270 4 726778653 19 -555910685 8 -453207364 19 8...
output:
8543939622
result:
ok single line: '8543939622'
Test #48:
score: 0
Accepted
time: 0ms
memory: 7256kb
input:
57 -352411323 1 -235887438 2 -796850581 3 -834615555 2 -148394946 4 290154112 4 91100627 5 605658328 5 324885645 4 320536700 3 -305226702 4 40001885 11 -150333687 5 -241155255 1 -872529131 13 598976255 6 -944949959 11 -712195821 18 -293414634 14 243382642 13 790978612 2 -198029874 18 89531966 7 4811...
output:
16825254531
result:
ok single line: '16825254531'
Test #49:
score: 0
Accepted
time: 4ms
memory: 8216kb
input:
76 -35542043 1 -979334111 1 -681777149 3 -431239157 4 173395821 2 -6789617 1 -123773414 7 239687023 5 828394792 5 716692022 3 78443387 2 -305979255 8 -147916771 2 -755315079 2 -705914850 7 84971069 1 -636839683 4 -859916790 15 609074923 6 -993481484 3 -828520796 10 -981040853 2 -370344141 8 63395735...
output:
20135303170
result:
ok single line: '20135303170'
Test #50:
score: 0
Accepted
time: 3ms
memory: 6768kb
input:
87 29235831 1 965485961 1 -350326700 2 -511480991 1 -511806164 3 921576849 5 923741062 2 -720356910 6 -808552295 5 -773377555 5 -404852529 10 295326021 8 114791609 4 858260472 14 -103063453 13 -957676222 16 -451976735 7 62596097 13 -728138588 9 -349452625 16 302626235 8 241850272 15 -4689832 9 58709...
output:
21674562383
result:
ok single line: '21674562383'
Test #51:
score: 0
Accepted
time: 0ms
memory: 10104kb
input:
36 863944850 1 522868615 1 -880954502 3 -450533862 1 327356103 3 -782212316 4 -865248751 4 877522108 7 775689428 2 126729557 3 -573520061 7 -718360621 4 -750646327 6 -6281669 13 439466195 7 638443819 14 914501444 16 360078932 11 464318178 4 836548306 15 -890015526 14 112391486 16 143122833 3 -464581...
output:
10612869318
result:
ok single line: '10612869318'
Test #52:
score: 0
Accepted
time: 4ms
memory: 9560kb
input:
9 -287755517 1 925971194 1 -520422161 1 -48478411 1 60693466 2 -918425716 2 477674024 4 -552632404 8 929024060
output:
2695383177
result:
ok single line: '2695383177'
Test #53:
score: 0
Accepted
time: 3ms
memory: 8288kb
input:
66 -457516264 1 458757638 2 953494542 1 452535680 4 71477499 1 229577469 5 52143211 7 -246007467 1 669299247 3 -541336589 2 213686903 9 -694906217 8 -726675303 8 -220353463 13 -458186092 5 60735391 9 77176950 7 755493826 10 -291863904 13 -30786170 12 323153067 11 518264638 20 573614035 2 583908546 9...
output:
15215005567
result:
ok single line: '15215005567'
Test #54:
score: 0
Accepted
time: 3ms
memory: 7412kb
input:
67 956827565 1 362832459 2 -527734290 1 784505769 3 552383291 4 -1132251 1 126891702 7 350930201 2 488691960 3 -468209649 9 -965598593 1 -141201776 3 509573808 1 220618317 2 -433082863 13 -35366994 1 -153361042 12 519616082 4 138505548 12 -317081052 14 -992883819 5 975510373 20 -139871799 10 -435462...
output:
12167507885
result:
ok single line: '12167507885'
Test #55:
score: 0
Accepted
time: 4ms
memory: 9536kb
input:
60 328053476 1 -861613151 2 291683606 2 713251706 3 592368607 4 -113303003 6 -217186284 7 -541013879 3 -549124915 7 -631148898 3 -696731503 10 426506154 9 -645376838 7 -796831807 6 608822789 8 -662585874 12 -692682874 15 -266926000 17 -671143919 6 820395465 13 112936526 21 378991364 6 921429756 19 1...
output:
15705981556
result:
ok single line: '15705981556'
Test #56:
score: 0
Accepted
time: 3ms
memory: 9888kb
input:
29 667923838 1 723290697 1 606003811 3 -238278586 3 -694934651 4 94392057 2 679326475 7 -74202245 5 284247214 4 770193005 9 332675159 6 133704635 12 -262232946 2 -938204814 12 -145285791 1 -835945681 6 388225798 7 605810036 2 804959292 9 -131024545 20 -225094504 21 11823368 17 -128739084 1 -40784358...
output:
4309781294
result:
ok single line: '4309781294'
Test #57:
score: 0
Accepted
time: 3ms
memory: 6904kb
input:
92 -35352527 1 -428264861 2 -201556345 1 -299453175 1 -607415443 2 -187246828 3 397633265 5 801431620 2 608699045 7 -944681272 10 -257580115 3 89954002 9 435379709 9 -743032998 7 -221464804 5 -882299003 6 101317999 16 267404597 16 79188400 5 -827608539 16 -264301977 11 656374108 7 -209168674 17 -487...
output:
23223400002
result:
ok single line: '23223400002'
Test #58:
score: 0
Accepted
time: 0ms
memory: 8468kb
input:
77 -803535848 1 -857479683 2 922951417 2 758786149 1 701181617 5 -139563371 5 -519409996 1 630541111 1 -527444716 2 -807883959 4 629045510 6 -437366954 1 -849618396 5 -184167420 4 549108630 7 -406193706 12 727626453 9 -137365347 3 -55362382 2 -506468352 3 -547293387 14 178976150 16 -338938343 14 -91...
output:
21852385020
result:
ok single line: '21852385020'
Test #59:
score: 0
Accepted
time: 4ms
memory: 6636kb
input:
17 -733390751 1 304457313 2 114654071 1 -381687668 1 143943150 3 -753458453 2 657584091 2 -88724697 3 125136898 7 -905804980 4 -140635776 2 -323154727 8 -639466826 4 74888171 12 -463278223 15 -951192816 6 -325391724
output:
2286100242
result:
ok single line: '2286100242'
Test #60:
score: 0
Accepted
time: 0ms
memory: 10048kb
input:
28 -564134869 1 -459219053 1 -39018318 3 -112741030 3 -264707861 2 616400122 6 -467842128 7 -754015360 6 -30934412 3 -212597243 4 -585045903 6 -414990103 7 -569433501 10 47577708 11 -568006592 7 373508601 15 -691426593 16 124649570 14 263537772 8 567150781 20 -467474863 3 405523105 3 -6070643 5 -315...
output:
5820475093
result:
ok single line: '5820475093'
Test #61:
score: 0
Accepted
time: 37ms
memory: 14804kb
input:
100000 146406075 1 -439023674 1 752982937 2 584809035 2 -874936229 3 931554617 3 -132609189 3 -699453735 5 -670746827 6 -831477279 6 -976680863 8 -281181925 9 -765582238 9 532952662 11 458413336 11 273078316 13 -310273593 15 527389377 15 54550067 16 -568043173 16 635794890 16 -310764910 20 -76866528...
output:
25141922468183
result:
ok single line: '25141922468183'
Test #62:
score: 0
Accepted
time: 18ms
memory: 23320kb
input:
100000 -576784279 1 -464955075 2 -904655763 3 67103909 4 -798832479 5 -671114288 6 -301251132 7 53954867 8 -794385744 9 975881275 10 -855242298 11 46624817 12 51366290 13 744310789 13 -63815909 14 47823238 16 -60346351 17 -419285434 18 -940621335 19 240879364 20 787038905 21 -354064397 22 -279627521...
output:
44776563713647
result:
ok single line: '44776563713647'
Test #63:
score: 0
Accepted
time: 32ms
memory: 14860kb
input:
100000 -999990200 1 -999989942 1 -999885985 1 -999882539 2 -999878827 2 -999878813 2 -999875068 3 -999865996 3 -999856973 4 -999835848 4 -999832772 6 -999798647 7 -999777469 8 -999770638 8 -999763735 9 -999762951 10 -999759411 10 -999699323 12 -999695258 12 -999690499 12 -999673663 13 -999553153 19 ...
output:
3658014457846
result:
ok single line: '3658014457846'
Test #64:
score: 0
Accepted
time: 15ms
memory: 23172kb
input:
100000 -999997417 1 -999987799 2 -999979274 3 -999978076 4 -999956762 5 -999915145 6 -999887391 7 -999878011 8 -999871273 9 -999851786 10 -999843924 11 -999843643 12 -999832720 12 -999794489 13 -999773704 15 -999745520 16 -999738391 16 -999704453 18 -999636195 19 -999616561 19 -999572050 20 -9995676...
output:
44917941374731
result:
ok single line: '44917941374731'
Test #65:
score: 0
Accepted
time: 31ms
memory: 14792kb
input:
100000 -999991662 1 -999966933 1 -999933624 1 -999931117 1 -999928124 2 -999926889 3 -999914780 3 -999905736 3 -999903634 3 -999888083 4 -999878315 4 -999866830 4 -999843858 4 -999837226 5 -999759739 6 -999737496 6 -999690536 7 -999688035 7 -999626158 7 -999595098 8 -999569311 9 -999523209 9 -999514...
output:
2601228295860
result:
ok single line: '2601228295860'
Test #66:
score: 0
Accepted
time: 27ms
memory: 23176kb
input:
100000 -999998474 1 -999981062 2 -999923760 3 -999899466 4 -999875590 5 -999871711 6 -999846972 7 -999844002 8 -999827708 9 -999819394 10 -999816444 10 -999800185 11 -999763157 13 -999748820 14 -999746086 15 -999712632 16 -999662863 17 -999640242 18 -999638889 19 -999636003 20 -999628559 21 -9996262...
output:
44732406711870
result:
ok single line: '44732406711870'
Test #67:
score: 0
Accepted
time: 25ms
memory: 14800kb
input:
100000 -999978081 1 -999966299 1 -999963110 1 -999959238 1 -999954883 1 -999928480 1 -999909134 1 -999905680 2 -999879251 2 -999869155 2 -999864152 4 397236241 5 -999844815 5 -999797450 6 -999786023 6 -999756043 7 -999689191 7 -810773905 7 -999679799 8 -999649497 8 -290033774 8 -999608082 9 -9995971...
output:
3461222654926
result:
ok single line: '3461222654926'
Test #68:
score: 0
Accepted
time: 26ms
memory: 23352kb
input:
100000 -999978841 1 -999933801 2 -999930902 3 -999902959 3 -999898058 5 -999887148 5 -999880689 7 -999859291 7 -999832783 8 -999762132 10 -999743314 11 -999741888 12 -999735891 13 -999735135 14 -999679127 14 -999674420 16 -999664049 17 -999631074 18 -999613703 19 -999603829 20 -999600801 21 -9996000...
output:
44642353314264
result:
ok single line: '44642353314264'
Test #69:
score: 0
Accepted
time: 33ms
memory: 14984kb
input:
100000 -999996198 1 -999973353 1 -505405391 1 691412 1 -999845508 1 -999828435 1 -999802267 1 -999778725 1 -999727609 2 -999727601 2 -457828756 3 -999699228 3 -999699036 4 -999622206 4 519733724 4 -999613580 4 -999605762 5 -614533426 5 -370202332 6 -999492433 6 -999492407 6 -999447753 8 -999433745 8...
output:
10142890208534
result:
ok single line: '10142890208534'
Test #70:
score: 0
Accepted
time: 19ms
memory: 23152kb
input:
100000 -999986531 1 -999976887 1 -999943096 2 -999935443 4 -999913478 5 -999905020 6 -999897168 7 -999870465 8 -999868133 9 -999851109 10 -999834181 11 -999831997 12 -999796543 13 194388646 14 -999736477 15 -999679928 16 -999640462 17 -999541881 18 -999531878 19 -999528741 20 -999460823 21 -99943027...
output:
44662108090618
result:
ok single line: '44662108090618'
Test #71:
score: 0
Accepted
time: 19ms
memory: 18784kb
input:
100000 40708999 1 -213178256 2 -229715520 3 -531486625 4 583309076 5 -781811564 5 206217116 5 441718630 8 724882316 8 204164253 8 -66591200 9 -83912610 12 371953418 13 8876509 14 -564032300 15 867719345 15 724048648 15 132263574 17 -773992679 18 562569244 18 665127636 18 86512702 21 -229334202 21 -5...
output:
35193130680421
result:
ok single line: '35193130680421'
Test #72:
score: 0
Accepted
time: 17ms
memory: 24340kb
input:
100000 472001141 1 726691560 2 -641232319 3 -868950595 4 398139017 5 -135761560 6 -886542149 7 -749905762 8 -387499703 9 559676768 10 -583111901 11 27894268 12 855255644 13 -564939574 14 -320793321 15 -109647403 16 392875264 17 -149475443 18 250372360 19 429092739 20 -1779235 21 156144596 22 -872195...
output:
47211003136274
result:
ok single line: '47211003136274'
Test #73:
score: 0
Accepted
time: 24ms
memory: 15476kb
input:
100000 768809350 1 604654996 2 354306730 2 -640866095 2 -305142535 3 -253602002 4 9359561 5 -885962335 6 -4240453 8 638713458 9 785275129 9 -271851223 10 787075061 10 504872865 11 -509752728 13 313626714 14 -741592755 15 534309869 15 -941252163 17 -45601750 18 -50826042 19 870444416 19 -424398897 20...
output:
32776214547603
result:
ok single line: '32776214547603'
Test #74:
score: 0
Accepted
time: 41ms
memory: 14200kb
input:
100000 586559961 1 26005494 1 852851647 2 -653055107 3 -831666770 4 -674500642 5 983473125 6 136633893 6 270192837 7 -976614174 8 -913176207 10 106462151 11 398009300 12 798691284 13 -656495173 14 -74718805 15 -539699021 16 226497205 16 -524016601 17 -765519268 18 -46575589 20 -812066089 21 82637980...
output:
44688064607000
result:
ok single line: '44688064607000'
Test #75:
score: 0
Accepted
time: 18ms
memory: 19960kb
input:
100000 121210376 1 183310454 1 556444695 2 -263512198 3 -246912259 4 841424843 5 -687721424 6 880082120 7 -452778011 8 690033584 9 -617354807 10 846392714 11 261554038 12 507227326 13 -440557366 14 117348711 15 -842757703 16 -806097521 17 -230715159 18 -755192797 19 -993836878 20 24740118 21 6348357...
output:
44428737547815
result:
ok single line: '44428737547815'
Test #76:
score: 0
Accepted
time: 24ms
memory: 18992kb
input:
100000 -999996842 1 -999964473 1 -999945411 1 -999869404 2 -999863656 3 -999848327 4 -999822868 5 -999817664 8 -999784165 9 -999770567 9 -999731439 9 -999694630 10 -999673388 11 -999545978 12 -999538059 13 -999500286 16 -999499202 16 -999480444 17 -999448168 17 -999408814 20 -999404403 21 -999385207...
output:
32058400120044
result:
ok single line: '32058400120044'
Test #77:
score: 0
Accepted
time: 24ms
memory: 24332kb
input:
100000 -999998097 1 -999973360 2 -999967811 3 -999920166 4 -999880510 5 -999877018 6 -999870611 7 -999836674 8 -999814692 9 -999813887 10 -999807840 11 -999758688 12 -999756983 13 -999755148 14 -999740304 15 -999738275 16 -999737399 17 -999729553 18 -999725897 19 -999723566 20 -999699293 21 -9996927...
output:
47036644742232
result:
ok single line: '47036644742232'
Test #78:
score: 0
Accepted
time: 28ms
memory: 15448kb
input:
100000 -999993375 1 -999918003 2 -999902241 2 -999898380 2 -999869188 3 -999866407 4 -999862811 5 -999833091 6 -999815555 7 -999814403 9 -999774647 9 -999753660 10 -999719788 10 -999667834 11 -999658125 12 -999635342 14 -999625710 15 -999619801 17 -999619258 17 -999609995 18 -999584066 19 -999582893...
output:
24598892987814
result:
ok single line: '24598892987814'
Test #79:
score: 0
Accepted
time: 31ms
memory: 14164kb
input:
100000 -999978271 1 -999968660 1 -999963316 2 -999950548 3 -999940906 4 -999933810 5 -999891801 6 -999865592 6 -999819897 7 -999806506 8 -999794432 10 -999786867 11 -999785750 12 -999763289 13 -999739914 14 -999714295 15 -999713942 16 -999679846 16 -999637060 17 -999630246 18 -999596369 20 -99957337...
output:
44444900010150
result:
ok single line: '44444900010150'
Test #80:
score: 0
Accepted
time: 15ms
memory: 20124kb
input:
100000 -999986001 1 -999977283 1 -999944697 2 -999940280 3 -999925916 4 -999889665 5 -999877584 6 -999874495 7 -999841578 8 -999828281 9 -999805324 10 -999800695 11 -999795539 12 -999774738 13 -999773943 14 -999770975 15 -999735107 16 -999688846 17 -999682565 18 -999641948 19 -999632279 20 -99959546...
output:
41194431398914
result:
ok single line: '41194431398914'
Extra Test:
score: 0
Extra Test Passed