QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#704029 | #129. Content Delivery | TheZone | AC ✓ | 363ms | 34600kb | C++20 | 2.4kb | 2024-11-02 19:08:31 | 2024-11-02 19:08:31 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
using LL = long long;
int main(){
#ifdef LOCAL
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int n, m;
cin >> n >> m;
vector<vector<pair<int, int> > > g(n + 1);
for(int i = 0; i < n - 1; i++){
int a, b, c;
cin >> a >> b >> c;
g[a].push_back({b, c});
g[b].push_back({a, c});
}
vector<int> c(n + 1);
for(int i = 1; i <= n; i++) cin >> c[i];
vector<LL> p;
p.reserve(n * n);
for(int i = 1; i <= n; i++){
auto dfs = [&](auto &&dfs, int u, int fa) -> int {
vector<int> v;
for(auto [j, w] : g[u]){
if (j == fa) continue;
int t = dfs(dfs, j, u) + w;
v.push_back(t);
}
if (v.empty()) return 0;
sort(v.begin(), v.end(), greater<>());
for(int j = 1; j < v.size(); j++){
p.push_back(1LL * c[i] * v[j]);
}
return v[0];
};
int t = dfs(dfs, i, -1);
p.push_back(1LL * c[i] * t);
}
sort(p.begin(), p.end(), greater<>());
if (p.size() > m) p.resize(m);
LL ans = 0;
for(auto x : p) ans += x;
cout << ans << '\n';
}
/*#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
using LL = long long;
int main(){
#ifdef LOCAL
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int n, m;
cin >> n >> m;
vector<vector<pair<int, int> > > g(n + 1);
for(int i = 0; i < n - 1; i++){
int a, b, c;
cin >> a >> b >> c;
g[a].push_back({b, c});
g[b].push_back({a, c});
}
vector<int> c(n + 1);
for(int i = 1; i <= n; i++) cin >> c[i];
vector<LL> p;
p.reserve(n * n);
for(int i = 1; i <= n; i++){
return v[0];
};
int t = dfs(dfs, i, -1);
p.push_back(1LL * c[i] * t);
}
sort(p.begin(), p.end(), greater<>());
if (p.size() > m) p.resize(m);
LL ans = 0;
for(auto x : p) ans += x;
cout << ans << '\n';
}*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
input:
6 14 1 3 9 1 6 8 2 3 1 3 4 29 4 5 28 23 23 9 1 10 15
output:
6074
result:
ok single line: '6074'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3828kb
input:
37 575 1 17 56 1 27 70 1 19 19 2 35 18 3 19 5 4 32 16 5 24 4 5 12 61 5 11 97 6 13 77 7 28 74 8 37 63 9 36 41 10 35 59 10 31 38 10 26 44 11 35 38 13 19 9 14 26 23 14 30 11 15 31 30 15 19 11 16 33 33 18 20 85 18 33 70 20 31 30 21 31 27 22 33 73 22 28 72 23 37 60 25 32 75 25 34 54 28 29 73 31 37 53 33 ...
output:
3485055
result:
ok single line: '3485055'
Test #3:
score: 0
Accepted
time: 39ms
memory: 6996kb
input:
863 299975 1 297 187 1 70 70 1 612 200 1 730 506 2 202 980 3 59 772 3 789 562 4 238 565 5 687 141 5 284 261 5 242 272 6 50 935 6 139 730 7 652 39 7 485 326 7 712 489 8 216 306 9 239 130 9 768 287 10 327 683 10 189 330 11 714 187 12 528 656 12 86 957 13 144 303 14 845 283 15 430 819 15 629 402 16 616...
output:
193505311222
result:
ok single line: '193505311222'
Test #4:
score: 0
Accepted
time: 249ms
memory: 17636kb
input:
2000 1593202 1 1279 1605 1 960 7046 2 27 8653 2 31 2383 2 1029 7113 3 866 169 3 1597 9722 3 362 5710 3 50 5591 4 1832 604 4 1351 141 5 1493 8043 6 473 9235 6 763 9009 6 707 4081 6 249 7396 6 84 7682 6 890 9665 7 1064 6600 7 1825 4987 7 1828 3920 8 1371 1591 9 197 1702 9 758 2662 9 943 7802 10 695 40...
output:
101374812913007
result:
ok single line: '101374812913007'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
7 9 1 6 23 1 5 30 2 5 19 3 6 4 4 5 14 5 7 13 22 11 1 20 16 30 3
output:
8190
result:
ok single line: '8190'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3616kb
input:
54 91 1 53 77 1 36 69 2 27 62 2 14 4 2 36 70 2 49 82 2 35 30 3 30 17 4 20 48 4 39 46 5 27 61 6 28 56 6 54 80 7 17 60 8 47 65 9 32 60 10 22 39 10 26 29 11 13 35 11 50 66 12 28 69 13 25 39 13 22 29 14 22 19 14 31 41 15 17 44 16 25 10 17 46 78 18 35 50 19 38 63 19 44 21 19 53 74 19 24 36 20 40 39 20 21...
output:
2344373
result:
ok single line: '2344373'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3556kb
input:
139 950 1 96 549 1 93 878 2 52 183 2 80 118 3 27 829 3 94 682 3 119 980 4 137 71 4 74 40 5 25 355 6 137 424 7 29 201 7 42 438 7 54 144 8 18 45 9 119 707 9 24 212 10 111 209 10 128 931 11 122 552 12 72 428 13 55 551 13 131 213 13 136 98 13 25 619 14 114 666 15 54 58 16 63 708 17 53 474 17 130 49 18 7...
output:
2539451060
result:
ok single line: '2539451060'
Test #8:
score: 0
Accepted
time: 236ms
memory: 16104kb
input:
2000 36782 1 1946 8493 2 79 4482 3 109 6652 4 153 5585 4 733 1557 4 883 3452 4 768 98 4 189 9833 5 1383 6855 5 133 726 6 1154 3906 7 1754 8270 7 377 561 7 1122 2590 7 1110 5060 8 1648 9319 8 1388 4019 9 827 3429 9 702 7121 9 163 1152 10 1639 18 10 201 3473 11 46 4665 12 1464 7016 13 1161 7061 13 423...
output:
21879537661372
result:
ok single line: '21879537661372'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3428kb
input:
10 17 1 8 26 2 8 18 3 6 23 3 9 22 4 7 30 5 6 2 6 10 26 7 9 7 7 8 30 13 13 29 1 19 11 17 17 2 25
output:
22234
result:
ok single line: '22234'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
84 261 1 64 10 1 72 46 2 17 22 2 8 30 2 15 16 3 46 63 4 84 87 4 49 63 4 35 100 5 73 88 6 24 43 6 21 60 6 66 55 7 59 82 9 43 30 10 29 91 11 19 16 12 27 6 12 31 7 12 67 91 13 14 62 13 83 1 13 17 100 13 54 93 15 51 82 16 32 32 16 22 53 16 76 30 16 59 93 16 72 2 16 40 76 17 53 11 18 70 71 18 20 81 19 32...
output:
6219651
result:
ok single line: '6219651'
Test #11:
score: 0
Accepted
time: 24ms
memory: 6164kb
input:
737 8381 1 212 186 1 57 319 2 683 725 3 599 542 3 275 307 4 90 177 4 627 997 4 439 357 5 372 811 5 474 583 5 712 55 6 33 325 7 248 834 7 477 211 8 238 190 8 282 749 9 228 692 10 618 321 10 191 728 11 79 184 11 548 746 11 301 780 11 270 774 12 249 820 13 63 430 13 583 998 14 308 55 14 533 829 15 215 ...
output:
43925455142
result:
ok single line: '43925455142'
Test #12:
score: 0
Accepted
time: 245ms
memory: 16368kb
input:
2000 61631 1 145 9910 1 517 5089 1 1573 9931 2 1956 8835 3 172 3723 3 1460 9157 3 1668 5703 4 1950 2219 5 264 6880 5 1118 541 6 701 1769 7 1547 7321 8 58 9405 8 1616 596 8 213 9267 8 1360 3617 8 1736 2592 9 269 7302 9 704 6236 9 1269 1211 10 343 3753 11 1016 4997 11 1252 4496 12 631 7235 12 1092 143...
output:
29783980377188
result:
ok single line: '29783980377188'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
7 9 1 6 13 2 5 17 2 6 24 3 7 1 3 5 12 4 6 15 9 2 6 12 24 8 16
output:
5551
result:
ok single line: '5551'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
62 23158 1 14 25 2 3 70 2 42 83 3 16 67 3 24 99 4 62 22 5 10 59 6 7 44 6 38 53 6 60 42 6 20 55 8 59 13 8 52 52 9 53 30 9 48 26 10 52 70 11 28 49 12 25 48 12 55 55 13 18 31 14 26 99 14 41 13 14 32 81 15 57 51 17 25 67 17 39 25 18 58 84 18 37 36 19 21 39 20 33 73 20 53 23 21 51 89 22 39 18 23 39 65 25...
output:
9932416
result:
ok single line: '9932416'
Test #15:
score: 0
Accepted
time: 40ms
memory: 5868kb
input:
868 82 1 335 1000 1 178 477 2 650 614 2 271 430 2 773 645 2 765 165 2 458 484 3 521 932 4 262 543 5 708 380 5 397 875 5 690 317 6 317 353 6 91 497 7 352 906 7 257 307 7 631 276 7 218 730 8 656 530 8 202 538 8 622 249 9 499 414 9 780 8 9 579 511 10 144 279 11 736 857 12 791 245 13 365 207 13 185 587 ...
output:
1938177021
result:
ok single line: '1938177021'
Test #16:
score: 0
Accepted
time: 246ms
memory: 16452kb
input:
2000 640 1 1829 5302 2 462 5700 2 1570 2474 3 1150 4469 4 1830 1087 4 23 1017 4 210 7804 5 1249 455 6 1396 8867 7 1084 7719 7 588 3893 8 68 3930 9 978 5203 9 485 7228 9 66 792 10 1248 8924 10 1640 7750 10 1663 3740 10 1742 3919 10 266 7413 11 1287 3910 11 848 3262 12 525 8629 12 1613 7773 12 119 172...
output:
2187081767074
result:
ok single line: '2187081767074'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
9 63 1 2 6 1 3 23 1 4 19 1 5 1 1 6 6 1 7 1 1 8 14 1 9 3 17 26 18 13 22 2 29 4 13
output:
10510
result:
ok single line: '10510'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3488kb
input:
14 168 1 2 14 1 3 78 1 4 76 1 5 88 1 6 24 1 7 37 1 8 62 1 9 63 1 10 51 1 11 71 1 12 92 1 13 49 1 14 54 46 73 14 62 1 79 62 42 38 12 83 49 46 77
output:
519142
result:
ok single line: '519142'
Test #19:
score: 0
Accepted
time: 33ms
memory: 6736kb
input:
675 454275 1 2 135 1 3 645 1 4 544 1 5 214 1 6 414 1 7 437 1 8 740 1 9 266 1 10 823 1 11 230 1 12 293 1 13 288 1 14 239 1 15 969 1 16 145 1 17 986 1 18 703 1 19 860 1 20 563 1 21 633 1 22 5 1 23 50 1 24 251 1 25 593 1 26 370 1 27 976 1 28 692 1 29 682 1 30 59 1 31 193 1 32 837 1 33 65 1 34 129 1 35 ...
output:
110884267997
result:
ok single line: '110884267997'
Test #20:
score: 0
Accepted
time: 363ms
memory: 34548kb
input:
2000 73528 1 2 4753 1 3 2119 1 4 35 1 5 9832 1 6 733 1 7 135 1 8 3228 1 9 7469 1 10 9 1 11 3934 1 12 8763 1 13 2994 1 14 9149 1 15 4916 1 16 512 1 17 57 1 18 8659 1 19 9971 1 20 1393 1 21 375 1 22 4362 1 23 2045 1 24 1237 1 25 2678 1 26 5253 1 27 147 1 28 4042 1 29 3892 1 30 1258 1 31 9663 1 32 6128...
output:
6449196778129
result:
ok single line: '6449196778129'
Test #21:
score: 0
Accepted
time: 359ms
memory: 34580kb
input:
2000 3996000 1 2 8917 1 3 5675 1 4 8721 1 5 6595 1 6 9652 1 7 9079 1 8 4148 1 9 7841 1 10 2393 1 11 2133 1 12 9565 1 13 1526 1 14 6915 1 15 1768 1 16 5466 1 17 3430 1 18 1729 1 19 2502 1 20 3693 1 21 5067 1 22 250 1 23 7482 1 24 3696 1 25 4431 1 26 2455 1 27 6081 1 28 9228 1 29 2915 1 30 5076 1 31 8...
output:
102580442548750
result:
ok single line: '102580442548750'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
4 3 1 2 15 1 3 19 1 4 3 30 16 20 27
output:
1844
result:
ok single line: '1844'
Test #23:
score: 0
Accepted
time: 1ms
memory: 3556kb
input:
50 107 1 2 81 1 3 94 1 4 74 1 5 46 1 6 57 1 7 11 1 8 100 1 9 91 1 10 85 1 11 31 1 12 24 1 13 50 1 14 4 1 15 31 1 16 100 1 17 85 1 18 17 1 19 40 1 20 36 1 21 38 1 22 84 1 23 71 1 24 99 1 25 77 1 26 84 1 27 22 1 28 2 1 29 3 1 30 20 1 31 69 1 32 61 1 33 74 1 34 69 1 35 58 1 36 88 1 37 98 1 38 74 1 39 8...
output:
983243
result:
ok single line: '983243'
Test #24:
score: 0
Accepted
time: 70ms
memory: 10500kb
input:
969 21823 1 2 790 1 3 864 1 4 404 1 5 369 1 6 370 1 7 443 1 8 40 1 9 877 1 10 675 1 11 137 1 12 271 1 13 306 1 14 193 1 15 806 1 16 804 1 17 800 1 18 771 1 19 863 1 20 662 1 21 244 1 22 761 1 23 425 1 24 594 1 25 806 1 26 739 1 27 224 1 28 248 1 29 628 1 30 472 1 31 145 1 32 689 1 33 212 1 34 232 1 ...
output:
18841369971
result:
ok single line: '18841369971'
Test #25:
score: 0
Accepted
time: 353ms
memory: 34600kb
input:
2000 88483 1 2 2930 1 3 2305 1 4 4623 1 5 8937 1 6 6930 1 7 8341 1 8 178 1 9 1863 1 10 9524 1 11 1973 1 12 8284 1 13 3218 1 14 1282 1 15 9919 1 16 8648 1 17 958 1 18 3196 1 19 328 1 20 3738 1 21 2737 1 22 5796 1 23 1689 1 24 3157 1 25 7460 1 26 7555 1 27 1148 1 28 3508 1 29 1142 1 30 9730 1 31 83 1 ...
output:
7712855758219
result:
ok single line: '7712855758219'
Test #26:
score: 0
Accepted
time: 358ms
memory: 34540kb
input:
2000 3996000 1 2 6073 1 3 5815 1 4 5579 1 5 6756 1 6 518 1 7 8066 1 8 8196 1 9 4186 1 10 3783 1 11 5515 1 12 9897 1 13 2847 1 14 9872 1 15 6366 1 16 3957 1 17 9847 1 18 9271 1 19 6253 1 20 2685 1 21 7678 1 22 5114 1 23 6139 1 24 9092 1 25 9139 1 26 9126 1 27 3297 1 28 36 1 29 7256 1 30 1840 1 31 751...
output:
100534977076639
result:
ok single line: '100534977076639'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
5 7 1 5 29 1 4 10 2 4 15 3 5 12 2 26 23 20 3
output:
4848
result:
ok single line: '4848'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
11 39 1 7 70 2 9 36 2 3 96 4 10 42 4 9 4 5 8 70 5 7 1 6 10 36 8 11 39 8 10 49 48 55 7 92 70 82 42 73 56 98 31
output:
289470
result:
ok single line: '289470'
Test #29:
score: 0
Accepted
time: 3ms
memory: 3648kb
input:
369 54463 1 40 542 1 281 187 1 324 258 1 124 104 2 145 575 2 31 471 2 281 782 3 59 522 3 79 958 4 210 880 4 139 897 4 305 258 4 177 571 4 268 787 4 38 264 5 191 791 5 316 863 5 112 358 6 9 786 6 353 609 7 214 960 8 185 829 8 158 141 9 87 294 9 162 766 10 240 807 10 242 543 11 174 687 12 341 885 12 1...
output:
36358871665
result:
ok single line: '36358871665'
Test #30:
score: 0
Accepted
time: 243ms
memory: 17900kb
input:
2000 65853 1 251 8993 2 1833 1956 3 1202 7940 3 1046 9296 4 1334 6739 4 55 422 5 1930 8132 5 1006 5197 5 887 596 5 1987 544 5 1824 1588 6 284 4995 7 130 7904 8 1892 3099 8 196 3750 9 733 9945 10 1913 1829 11 1082 8664 12 774 3684 12 905 3800 13 705 2838 14 807 6938 14 694 8587 14 597 1726 15 1258 15...
output:
31390425003957
result:
ok single line: '31390425003957'
Test #31:
score: 0
Accepted
time: 245ms
memory: 16764kb
input:
2000 1591203 1 1457 3871 2 1210 2752 3 1229 1219 3 118 5218 3 1970 2574 3 1877 1949 3 408 4319 3 1868 9145 3 211 8439 4 754 1197 5 1747 1556 6 1937 5014 6 1981 8465 7 682 5846 8 1826 6541 9 25 62 10 1512 6458 10 1200 4288 11 914 4774 11 104 5087 11 1285 4336 12 587 3336 13 24 2052 13 1614 198 14 491...
output:
100050913856939
result:
ok single line: '100050913856939'
Test #32:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
9 2 1 8 24 1 7 30 1 5 13 2 8 21 3 6 17 4 5 18 5 6 17 6 9 19 10 1 8 3 24 28 12 20 28
output:
4732
result:
ok single line: '4732'
Test #33:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
35 136 1 16 91 1 10 86 1 26 36 2 7 76 2 24 2 3 19 95 4 35 81 5 19 84 5 15 9 5 21 91 6 12 77 7 28 17 7 11 53 8 23 35 8 25 42 9 14 35 9 25 89 10 29 18 11 18 8 12 26 79 13 16 17 15 31 65 15 22 1 16 30 54 17 33 76 18 23 81 18 19 85 19 34 82 19 27 38 20 28 82 21 33 16 23 35 87 24 30 86 26 32 69 15 99 4 7...
output:
2893327
result:
ok single line: '2893327'
Test #34:
score: 0
Accepted
time: 3ms
memory: 3568kb
input:
217 602 1 133 809 2 19 126 2 86 497 2 17 573 3 159 816 3 98 197 3 150 853 4 86 955 5 91 407 5 68 442 5 124 10 6 51 551 7 37 714 7 109 166 7 209 247 8 163 629 8 41 763 8 104 960 9 206 24 9 194 124 10 11 662 10 211 129 11 96 690 11 195 92 11 111 927 12 65 981 12 31 646 13 86 324 14 130 494 14 116 643 ...
output:
3698228927
result:
ok single line: '3698228927'
Test #35:
score: 0
Accepted
time: 250ms
memory: 17196kb
input:
2000 26833 1 1793 3664 2 1815 1683 3 201 3046 4 1757 2310 4 1190 7900 5 1578 970 6 1513 399 6 1464 1786 7 650 334 7 1844 4901 8 1967 5357 8 1437 4036 9 1092 9646 9 1440 3999 9 1030 130 9 1747 4155 10 1705 3244 10 1308 9015 10 594 3192 10 1624 1417 11 1008 7915 12 650 4131 12 1364 5580 12 927 2890 13...
output:
19156885143548
result:
ok single line: '19156885143548'
Test #36:
score: 0
Accepted
time: 249ms
memory: 15828kb
input:
2000 1599199 1 251 9632 2 960 8077 2 416 1661 3 1569 4243 3 791 670 3 156 1766 3 1540 7829 4 1436 1174 5 214 7396 5 562 318 5 1541 9483 6 929 3117 6 128 7281 6 1621 9864 7 508 1376 8 344 1693 8 1885 6199 8 626 2555 9 1099 3771 10 13 3665 11 1072 7102 11 692 8725 11 1880 3763 11 236 9239 12 298 3345 ...
output:
100018114597410
result:
ok single line: '100018114597410'
Test #37:
score: 0
Accepted
time: 1ms
memory: 3608kb
input:
96 6459 1 51 1 2 68 33 82 3 68 23 4 27 25 5 66 6 27 24 75 7 2 8 30 46 9 95 63 10 95 16 80 10 33 65 10 100 11 10 18 13 11 100 11 35 78 82 11 22 25 12 30 12 38 60 43 12 97 12 42 42 23 14 97 14 20 41 89 14 25 34 14 34 30 14 90 58 15 47 82 16 83 17 85 61 18 25 75 19 40 7 92 21 92 75 22 65 51 23 33 23 67...
output:
21985820
result:
ok single line: '21985820'
Test #38:
score: 0
Accepted
time: 2ms
memory: 3548kb
input:
167 25231 88 1 864 2 93 928 167 3 158 114 4 539 5 167 374 49 6 669 7 159 643 109 8 388 37 8 656 40 8 877 38 8 540 36 8 29 32 8 545 8 21 212 133 8 75 33 8 45 8 157 548 88 9 475 10 142 940 11 157 401 12 48 486 85 13 713 14 109 303 155 15 711 16 85 619 93 17 144 124 18 560 88 19 479 167 20 951 155 22 7...
output:
6635791308
result:
ok single line: '6635791308'
Test #39:
score: 0
Accepted
time: 325ms
memory: 33504kb
input:
2000 111326065 1 289 8230 2 1640 2156 289 3 2544 4 1412 730 5 738 4620 6 416 2091 7 415 8667 8 834 9154 9 1615 8766 840 10 1158 840 11 1127 131 12 6018 1355 13 6554 631 14 4361 1412 15 7813 207 16 8814 1158 17 4895 415 18 5019 1204 19 6356 20 914 532 303 21 5939 22 834 7263 1910 23 1744 1910 24 4667...
output:
100461910024830
result:
ok single line: '100461910024830'
Test #40:
score: 0
Accepted
time: 327ms
memory: 33548kb
input:
2000 3870063 732 1 1786 196 2 8939 3 1479 6827 4 1479 4234 451 5 8346 422 6 4798 7 707 9885 162 8 63 9 444 6312 10 1557 3545 10 258 3658 10 721 5223 1960 10 7869 1198 10 9188 10 392 8241 10 644 2514 10 880 2765 10 1009 439 10 189 9413 469 10 3603 10 1826 7282 75 10 5358 10 55 5041 10 1325 4116 10 16...
output:
99905718280273
result:
ok single line: '99905718280273'
Test #41:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
26 125 1 13 92 20 1 18 1 14 24 1 19 51 2 13 28 13 3 88 23 4 96 5 9 40 15 6 80 19 7 72 8 19 70 8 17 81 8 11 44 23 8 51 9 23 64 18 10 83 12 15 58 13 18 34 22 13 19 21 15 36 15 18 39 16 19 40 26 18 90 24 19 16 23 25 15 93 82 53 27 46 50 30 22 2 22 76 36 10 29 67 78 26 14 13 95 69 17 73 6 26 97
output:
1126910
result:
ok single line: '1126910'
Test #42:
score: 0
Accepted
time: 40ms
memory: 7492kb
input:
775 1945 1 436 27 595 2 835 2 205 833 533 2 780 258 2 734 323 2 468 2 312 403 292 2 633 698 2 32 64 2 519 430 2 663 3 34 107 4 144 133 687 5 142 6 735 508 7 214 169 8 215 787 9 246 483 262 10 335 11 222 851 34 12 543 13 290 72 498 14 753 15 596 557 417 16 12 290 17 901 290 18 125 19 541 107 20 29 48...
output:
16976547470
result:
ok single line: '16976547470'
Test #43:
score: 0
Accepted
time: 323ms
memory: 34100kb
input:
2000 73152 778 1 3934 2 166 3010 1755 3 5385 183 4 9186 712 5 2826 968 6 9638 7 931 2497 1154 8 3103 9 166 8105 712 10 6494 283 11 7266 931 12 7595 1541 13 9722 14 991 5245 15 1905 9085 16 1865 9666 536 17 2264 1154 18 9635 19 1493 8981 20 541 7825 21 1839 6504 1755 22 208 23 968 7106 1326 24 3354 2...
output:
8057284624285
result:
ok single line: '8057284624285'
Test #44:
score: 0
Accepted
time: 321ms
memory: 34032kb
input:
2000 3930033 1250 1 8354 2 1351 8243 3 1609 2829 4 1609 7279 5 949 697 935 6 3408 7 809 6193 747 8 7862 9 1751 6987 1805 10 3875 19 11 1264 1520 12 2061 13 1343 8092 1505 14 3960 525 15 9574 16 1343 3663 1751 17 6238 670 18 6310 19 1609 4445 19 1131 4644 19 188 9762 19 20 1354 19 1381 1136 800 19 36...
output:
102636015955390
result:
ok single line: '102636015955390'
Test #45:
score: 0
Accepted
time: 259ms
memory: 20716kb
input:
2000 79809 520 1 2370 2 1932 5854 2 1867 4067 512 2 24 427 3 2314 4 1266 3338 5 794 4333 5 887 4445 5 965 7355 1168 6 540 6 1458 8775 1123 6 7576 7 1968 6914 8 483 9845 9 235 3674 10 335 4492 307 11 6869 12 1754 6627 13 265 2439 14 1266 9706 14 31 1371 14 1871 7761 1903 15 667 16 1302 8428 17 965 97...
output:
22204313422312
result:
ok single line: '22204313422312'
Test #46:
score: 0
Accepted
time: 266ms
memory: 20812kb
input:
2000 2086955 1 703 1838 1340 1 4167 37 1 6911 601 2 1561 1776 3 5302 3 853 7986 625 3 5942 1703 3 8661 4 867 1537 1584 4 6275 829 4 2880 5 1610 8710 5 842 7544 5 1799 8283 5 1117 4051 417 6 2692 7 774 261 1453 7 7886 8 1482 1068 1659 8 6801 9 1866 5396 9 1159 9185 9 1263 5759 836 10 3462 1576 11 847...
output:
102859136342336
result:
ok single line: '102859136342336'
Test #47:
score: 0
Accepted
time: 262ms
memory: 20736kb
input:
2000 2164 386 1 9446 2 1474 1037 2 626 8143 1307 3 57 3 71 1770 1036 3 632 3 687 803 4 1672 6394 4 1337 2818 1079 5 2225 5 1064 4302 883 6 2790 6 152 4433 1656 6 2149 1192 6 6027 551 7 4782 574 8 9173 8 112 9849 9 1807 3898 10 828 2364 611 10 1945 386 10 9705 1317 10 938 535 11 9172 12 896 26 12 125...
output:
2171982628171
result:
ok single line: '2171982628171'
Test #48:
score: 0
Accepted
time: 258ms
memory: 19464kb
input:
2000 1979009 1 410 9299 42 2 7097 698 2 1100 2 13 7883 370 2 1632 2 1787 554 68 3 7037 3 1584 6944 4 192 2221 5 880 8048 6 1544 9250 1684 6 1222 7 428 5711 1834 7 4553 627 7 5706 219 8 8795 1183 8 6581 8 1732 2415 9 1358 3742 668 10 2668 11 1414 2739 258 11 7490 1009 11 4596 1174 12 597 265 12 5258 ...
output:
102529122489292
result:
ok single line: '102529122489292'
Test #49:
score: 0
Accepted
time: 259ms
memory: 19952kb
input:
2000 29703 959 1 3789 1 811 9698 1 1654 8610 1 397 2739 2 832 5044 1727 2 2341 3 1142 6447 4 1318 59 854 4 1803 5 1809 857 1574 6 1995 6 69 3138 6 798 6063 6 1929 9541 1584 7 8009 899 8 903 9 1935 1962 12 9 17 1510 10 7833 10 172 5754 1759 10 2781 10 619 1273 10 163 6564 95 11 4806 12 1992 3322 1450...
output:
14989371839271
result:
ok single line: '14989371839271'
Test #50:
score: 0
Accepted
time: 251ms
memory: 19732kb
input:
2000 1957020 1 798 6267 1957 1 2312 470 1 8792 170 1 3676 1730 2 5190 951 2 4545 604 3 2035 1575 3 1648 4 1174 5356 1896 4 692 5 1094 9258 432 6 4081 218 6 9265 1146 7 1869 1938 8 3458 1947 8 3066 9 407 1661 10 1894 8829 1223 11 1285 11 160 5818 1460 11 3764 11 1913 1307 12 1025 7028 13 115 7592 14 ...
output:
102544069971160
result:
ok single line: '102544069971160'
Test #51:
score: 0
Accepted
time: 53ms
memory: 7532kb
input:
995 495011 1 2 946 1 3 163 2 4 810 2 5 57 3 6 5 3 7 579 4 8 19 4 9 829 5 10 160 5 11 960 6 12 791 6 13 885 7 14 805 7 15 774 8 16 133 8 17 334 9 18 191 9 19 731 10 20 533 10 21 938 11 22 154 11 23 71 12 24 725 12 25 134 13 26 78 13 27 431 14 28 677 14 29 805 15 30 224 15 31 883 16 32 48 16 33 617 17...
output:
238918764265
result:
ok single line: '238918764265'
Test #52:
score: 0
Accepted
time: 236ms
memory: 19472kb
input:
2000 105 1 2 8795 1 3 398 2 4 8818 2 5 2187 3 6 7212 3 7 8957 4 8 7042 4 9 7400 5 10 407 5 11 2184 6 12 3310 6 13 9827 7 14 1009 7 15 7162 8 16 3894 8 17 9771 9 18 6555 9 19 9216 10 20 6956 10 21 6190 11 22 2081 11 23 176 12 24 4628 12 25 9569 13 26 4275 13 27 2118 14 28 5481 14 29 5459 15 30 514 15...
output:
124803404146
result:
ok single line: '124803404146'
Test #53:
score: 0
Accepted
time: 239ms
memory: 21120kb
input:
2000 1998999 1 2 7732 1 3 7337 2 4 8380 2 5 4378 3 6 6935 3 7 9115 4 8 7762 4 9 7782 5 10 172 5 11 9607 6 12 9480 6 13 3110 7 14 1881 7 15 5517 8 16 658 8 17 9832 9 18 5172 9 19 361 10 20 4420 10 21 1407 11 22 6537 11 23 6868 12 24 9699 12 25 1887 13 26 4410 13 27 5470 14 28 4572 14 29 7018 15 30 54...
output:
99974220189091
result:
ok single line: '99974220189091'
Test #54:
score: 0
Accepted
time: 13ms
memory: 4228kb
input:
476 3132 1 2 583 1 3 738 2 4 933 2 5 646 3 6 695 3 7 936 4 8 229 4 9 647 5 10 120 5 11 480 6 12 627 6 13 323 7 14 901 7 15 855 8 16 822 8 17 597 9 18 154 9 19 194 10 20 791 10 21 822 11 22 233 11 23 375 12 24 157 12 25 735 13 26 643 13 27 61 14 28 954 14 29 667 15 30 5 15 31 897 16 32 791 16 33 920 ...
output:
10844207407
result:
ok single line: '10844207407'
Test #55:
score: 0
Accepted
time: 245ms
memory: 19468kb
input:
2000 85193072 1 2 5106 1 3 5300 2 4 9076 2 5 9707 3 6 5705 3 7 8657 4 8 4375 4 9 1886 5 10 6935 5 11 2072 6 12 7725 6 13 4336 7 14 1735 7 15 7936 8 16 6161 8 17 4124 9 18 5711 9 19 4155 10 20 2584 10 21 498 11 22 6125 11 23 8570 12 24 4701 12 25 9474 13 26 9652 13 27 9486 14 28 989 14 29 1736 15 30 ...
output:
102713418022810
result:
ok single line: '102713418022810'
Test #56:
score: 0
Accepted
time: 239ms
memory: 20272kb
input:
2000 1998999 1 2 2648 1 3 5611 2 4 5629 2 5 9790 3 6 1873 3 7 4456 4 8 2421 4 9 9282 5 10 3731 5 11 6584 6 12 4969 6 13 6251 7 14 4048 7 15 4429 8 16 1482 8 17 5471 9 18 4620 9 19 7474 10 20 1520 10 21 2644 11 22 2109 11 23 6597 12 24 702 12 25 6856 13 26 6169 13 27 5300 14 28 394 14 29 4589 15 30 8...
output:
99904015988171
result:
ok single line: '99904015988171'
Test #57:
score: 0
Accepted
time: 125ms
memory: 3932kb
input:
2000 1000000000 1 2 10000 2 3 10000 3 4 10000 4 5 10000 5 6 10000 6 7 10000 7 8 10000 8 9 10000 9 10 10000 10 11 10000 11 12 10000 12 13 10000 13 14 10000 14 15 10000 15 16 10000 16 17 10000 17 18 10000 18 19 10000 19 20 10000 20 21 10000 21 22 10000 22 23 10000 23 24 10000 24 25 10000 25 26 10000 2...
output:
399800000000000
result:
ok single line: '399800000000000'
Test #58:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
2 1 1 2 1 1 1
output:
1
result:
ok single line: '1'
Extra Test:
score: 0
Extra Test Passed